HTML <fieldset> Tag

Topic: HTML5 Tags Reference« Prev|Next »

Description

The <fieldset> tag specifies a set of form fields. It is generally used to group logically related controls and labels within a web form. Grouping form controls makes it easier for users to understand their purpose and makes the documents more accessible.

The following table summarizes the usages context and the version history of this tag.

Placement: Block
Content: <legend> as first child; after that block, inline, and text
Start/End Tag: Start tag: required, End tag: required
Version: HTML 4, 4.01, 5

Syntax

The basic syntax of the <fieldset> tag is given with:

HTML / XHTML: <fieldset> ... </fieldset>

The example below shows the <fieldset> tag in action.

  • <form action="http://www.example.com/" method="post">
  •     <fieldset>
  •         <legend>Gender</legend>
  •         <input type="radio" name="gender" value="male" id="male">
  •         <label for="male">Male</label>
  •         <input type="radio" name="gender" value="female" id="female">
  •         <label for="female">Female</label>
  •     </fieldset>
  • </form>

Tag-Specific Attributes

The <fieldset> tag doesn't have any specific attribute.


Global Attributes

Like all other HTML tags, the <fieldset> tag supports the global attributes in HTML5.


Event Attributes

The <fieldset> tag also supports the event attributes in HTML5.


Browser Compatibility

The <fieldset> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 4+
  • Apple Safari 1+
  • Opera 4+

Further Reading

See tutorial on: HTML Forms.

Related tag: <legend>, <form>.

 
Close

Your Feedback:

 

We would love to hear from you! Please say something.