HTML <legend> 标签

定义和用法

legend 元素为 fieldset 元素定义标题(caption)。

实例

组合表单中的相关元素:

<form>
  <fieldset>
    <legend>health information</legend>
    height: <input type="text" />
    weight: <input type="text" />
  </fieldset>
</form>

TIY

HTML 与 XHTML 之间的差异

在 HTML 4.01 中,align 属性不被赞成使用。

在 XHTML 1.0 Strict DTD 中,align 属性不被支持。

可选的属性

DTD 指示此属性允许在哪种 DTD 中使用。S=Strict, T=Transitional, F=Frameset.

属性 描述 DTD
align
  • top
  • bottom
  • left
  • right

不赞成使用。请使用样式代替。

为 fieldset 中的标题定义对齐方式。

TF

标准属性

id, class, title, style, dir, lang, xml:lang

如需完整的描述,请访问标准属性

事件属性

accesskey, onclick, ondblclick, onmousedown, onmouseup, onmouseover,
onmousemove, onmouseout, onkeypress, onkeydown, onkeyup

如需完整的描述,请访问事件属性

TIY 实例

围绕数据的 Fieldset
本例演示如何在数据周围绘制一个带标题的框。