当前位置: 首页 > 网络学院 > 网页制作基础教程 > HTML > HTML <option>标签
The option element defines an option in the drop-down list.
option元素定义了下拉列表的可选项目
In HTML the <option> tag has no end tag.
HTML中<option>标签不需要关闭
In XHTML the <option> tag must be properly closed.
在XHTML中<option>标签必须合理关闭
Note: The <option> tag can be used without any attributes, but you usually need the value attribute, which indicates what is sent to the server.
注意:<option>标签不需要任何属性,但一般情况下应该需要value属性,这可以表明发送给服务器的是什么值
Note: Use this tag in conjunction with the select element, elsewhere it is meaningless.
注意:这个标签应该和select元素一起使用,不然它一点意义也没有
代码 | 输出 |
---|---|
<select> <option value ="volvo">Volvo</option> <option value ="saab">Saab</option> <option value ="opel" selected="selected">Opel</option> <option value ="audi">Audi</option> </select> |
DTD indicates in which DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.
下表中的DTD列指明了被支持的DTD属性。S=Strict(精确的),T=Transitional(传统的),F=Frameset(框架)
属性 | 值 | 描述 | DTD |
---|---|---|---|
disabled | disabled | Specifies that the option should be disabled when it first loads 当它第一次被加载的时候可选项不可用 | STF |
label | text | Defines a label to use when using <optgroup> 当使用<optgroup>时定义一块标签 | STF |
selected | selected | Specifies that the option should appear selected (will be displayed first in the list) 指定为默认选中的项目 | STF |
value | text | Defines the value of the option to be sent to the server 定义可选项发送到服务器上的值 | STF |
id, class, title, style, dir, lang, xml:lang, tabindex |
For a full description, go to Standard Attributes.
查看完整的属性
onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup |
For a full description, go to Event Attributes.
查看完整的属性
Simple drop down box
How to create a simple drop-down box on an HTML page. A drop-down box is a selectable list.
如何在HTML中建立简单的下拉框。
Another drop down box
How to create a simple drop-down box with a pre-selected value.
如何建立带有预选值的下拉框