当前位置: 首页 > 网络学院 > 网页制作基础教程 > HTML > HTML <option>标签

HTML
HTML 介绍
HTML 元素
HTML 基本标签
HTML 格式
HTML 实体字符
HTML 链接
HTML 框架
HTML 表格
HTML 列表
HTML 表单
HTML 图片
HTML 背景
HTML 颜色
HTML 颜色值
HTML 颜色名
HTML 便条
HTML 布局
HTML 字体
HTML 4.0
HTML 样式

HTML <option>标签


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 489 ::
收藏到网摘: n/a

定义与用法

The option element defines an option in the drop-down list.
option元素定义了下拉列表的可选项目


在HTML和XHTML中的区别

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.
如何建立带有预选值的下拉框

评论 (0) All

登陆 | 还没注册?