HTML <legend> 标签

html <legend> 元素为 <fieldset> 元素定义标题

属性

属性 描述
align top
bottom
left
right
html5 不支持,HTML 4.01 已废弃
不建议使用,请使用样式代替
为 fieldset 中的标题定义对齐方式


范例

组合表单中的相关元素

<form>
    <fieldset>
        <legend>Personalia:</legend>
        Name: <input type="text" size="30"><br>
        Email: <input type="text" size="30"><br>
        Date of birth: <input type="text" size="10">
    </fieldset>
</form>

HTML 4.01 与 HTML5之间的差异

HTML 4.01 中 "align" 属性已被废弃,HTML5 不支持该属性,不建议使用

可以使用 css 来设置 <legend> 元素的对齐方式