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

HTML Reference Manual

HTML Tag Directory

HTML: <fieldset> tag

HTML <fieldset> tag is located within the <form> tag and is used to group related elements in HTML forms. Use the <legend> tag to create a title for the <fieldset>. This tag is also commonly referred to as the <fieldset> element.

Online Example

Group related elements in the form:

!doctype html
<html>
<head>
<meta charset="UTF-8">
<title>HTML5 Usage of fieldset tag (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 and see ‹/›

The effect after running is as follows:

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the <fieldset> tag.

Definition and Usage of Tag

The <fieldset> tag can group related elements within a form.

The <fieldset> tag draws a border around the surrounding form elements.

Most browsers will display a black border around the <fieldset> tag, but you can use CSS to change this behavior.

You can use the <legend> tag to display the title of the <fieldset>. This title will be presented before the related form controls within the <fieldset> and will appear floating above the top border of the <fieldset>.

Tips and Notes

Tip:<legend> The <legend> tag defines a title for the <fieldset> element.

HTML 4.01 Between HTML5Differences

HTML5 New attributes added to <fieldset> in HTML: disabled, form, name, HTML 4.01 These attributes are not supported in Chinese.

Attribute

AttributeValueDescription
disabledHTML5disabledSpecifies that the form elements in this group should be disabled.
formHTML5form_idSpecifies one or more forms that the fieldset belongs to.
nameHTML5textSpecifies the name of the fieldset.

Global Attributes

Support for <fieldset> tag Global Attributes of HTML.

Event Attributes

Support for <fieldset> tag HTML Event Attributes.