If you find this helpful, please click the Google Button to the left, if it is white, to make it turn blue or red. Thank you! (It also helps find this page again more easily.) |
The <fieldset> Tag in HTML 5
The <fieldset> tag is used to label a set of related fields, usually in an HTML form. It is one of the sectioning root tags, which means that the sections and headings inside the fieldset element are not included in the outline of any higher level sections.
<fieldset> Tag Syntax
<body> ... ... flow content expected ... <form id="form-id" method="GET|POST|etc." action="target-URL"> ... ... phrasing content expected ...<fieldset>... phrasing content ... ... phrasing content ...</fieldset>... ... </form> ... ... phrasing content expected ...<fieldset form="form-id">... phrasing content ... ... phrasing content ...</fieldset>... ... </body>
Rules for coding HTML fieldset elements
Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.
- Code the fieldset element where phrasing content is expected, usually inside a form element.
- Begin the fieldset element with a starting <fieldset> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the
xmlns
attribute on the <html> tag. - If the field set is for a form that can be submitted but is outside that form element, include a
form
attribute referencing the form the fieldsetis to be associated with. - Include any other attributes on the <fieldset> tag as appropriate.
- Inside the fieldset element, between the starting
<fieldset>
tag and the ending</fieldset>
tag, code the inner HTML phrasing content. - End the fieldset element with a matching
</fieldset>
closing tag.
Content Model
Contents of the fieldset element
- optional <legend> tag
- The first child element of a <fieldset> tag may be a <legend> tag.
The content of the fieldset element can include HTML comments, text content and only those HTML tags that can be used in phrasing content.
<fieldset> Tag Attributes
Attributes of the <fieldset> tag
global attributes | In addition to the personal attributes of the <fieldset> tag below, any of the common HTML attributes can also be coded. |
<fieldset> Tag Examples
Examples of the fieldset
tag in HTML 5
Changes in HTML 5 - <fieldset> Tag
What's new in HTML 5
The disabled="disabled" and form attributes have been added.
Differences between HTML 5 and earlier versions of HTML
The 2000-2010 Recommendations from the W3C HTML Working Group defined the HTML namespace for the fieldset element type name along with the names of all HTML element types. In older (pre-2000) versions of HTML, element type names were not associated with a namespace.