<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.