English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML: <legend> tag

When grouping related items in an HTML form, the HTML <legend> tag is used to generate a title for the <fieldset> tag. This tag is also commonly referred to as the <legend> element.

Online Example

Combine related elements in a form:

!doctype html
<html>
<head>
<meta charset="UTF-8">
<title>HTML5 Using fieldset tags (Basic Tutorial Website oldtoolbag.com)</title>
</head>
<body>
<form>
  <fieldset>
    <legend>Customer Information(oldtoolbag.com)</legend>
    Name: <input type="text"><br>
    Address: <input type="text"><br>
    Phone Number: <input type="text">
  </fieldset>
</form>
</body>
</html>
Test it out ‹/›

In this HTML5In the document example, we created a <legend> tag that provides a title for the three groups of <input> controls. The <legend> tag will display the title 'Customer Information' above these grouped controls.3codebox.com)

Browser Compatibility

IEFirefoxOperaChromeSafari

Most web browsers support the <legend> tag at present.

Tag Definition and Usage Description

 The <legend> element is <fieldset>element defines the title.

The title generated by the <legend> tag will be presented before the relevant form controls within the <fieldset> and will appear to float above the top border of the <fieldset>.

HTML 4.01 with HTML5differences

In HTML  4.01The 'align' attribute has been deprecated, HTML5This attribute is not supported. Not recommended for use. Use CSS to set the alignment of the <legend> element.

Attribute

AttributeValueDescription
aligntop
bottom
left
right
HTML5 Not supported. HTML 4.01 Deprecated. Not recommended for use. Use styles instead. Define alignment for the title within fieldset.

Global Attributes

<legend> tag supports global attributes, see the complete attribute table HTML Global Attributes.

event attributes

<legend> tag supports all HTML Event Attributes.