<option>: The HTML Option element - HTML: HyperText Markup Language 编辑

The HTML <option> element is used to define an item contained in a <select>, an <optgroup>, or a <datalist> element. As such, <option> can represent menu items in popups and other lists of items in an HTML document.

Content categoriesNone.
Permitted contentText, possibly with escaped characters (like &eacute;).
Tag omissionThe start tag is mandatory. The end tag is optional if this element is immediately followed by another <option> element or an <optgroup>, or if the parent element has no more content.
Permitted parentsA <select>, an <optgroup> or a <datalist> element.
Implicit ARIA roleoption
Permitted ARIA rolesNo role permitted
DOM interfaceHTMLOptionElement

Attributes

This element includes the global attributes.

disabled
If this Boolean attribute is set, this option is not checkable. Often browsers grey out such control and it won't receive any browsing event, like mouse clicks or focus-related ones. If this attribute is not set, the element can still be disabled if one of its ancestors is a disabled <optgroup> element.
label
This attribute is text for the label indicating the meaning of the option. If the label attribute isn't defined, its value is that of the element text content.
selected
If present, this Boolean attribute indicates that the option is initially selected. If the <option> element is the descendant of a <select> element whose multiple attribute is not set, only one single <option> of this <select> element may have the selected attribute.
value
The content of this attribute represents the value to be submitted with the form, should this option be selected. If this attribute is omitted, the value is taken from the text content of the option element.

Examples

See <select> for examples.

Specifications

SpecificationStatusComment
HTML Living Standard
The definition of '<option>' in that specification.
Living Standard
HTML5
The definition of '<option>' in that specification.
Recommendation
HTML 4.01 Specification
The definition of '<option>' in that specification.
RecommendationInitial definition

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:101 次

字数:7506

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文