HTML <fieldset> Tag

The <fieldset> tag visually groups logically related fields in an HTML form defined with the <form> tag. The tag allows breaking forms down into logical sections. In browsers, a box around the content is drawn.


The <fieldset> tag comes in pairs. The content is written between the opening (<fieldset>) and closing (</fieldset>) tags.

Example of the HTML <fieldset> tag:

<!DOCTYPE html>
    <title>Title of the document</title>
      div {
        margin-bottom: 10px;
      label {
        display: inline-block;
        width: 120px;
      fieldset {
        background: #e1eff2;
      legend {
        padding: 20px 0;
        font-size: 20px;
        <legend>Personal Information:</legend>
          <label for="name">Name:</label>
          <input type="text" id="name">
          <label for="email">Email:</label>
          <input type="email" id="email">
          <label for="date">Date of birth:</label>
          <input type="number" id="date">
          <label for="birth-day">Place of birth:</label>
          <input type="text" id="birth-day">


fieldset example

The <fieldset> element for organizing forms

The majority of online forms is hard to use and disorganized. Here, the best thing for organizing your online form is arranging them into logical sections. You can use the <fieldset> element for this purpose. It allows break forms down into logical segments. Using it with the <legend> element will be more effective and will make your forms easy to use.


Attribute Value Description
disabled disabled Indicates that a group of related form elements must be disabled.
form form_id Defines one or more form identifiers (id), to which the set of related elements belongs. If there are several identifiers, then they must be separated by spaces.
name text Defines a name for the joined group of items. The name in the browser is not displayed, it is used in the work of scripts.

The <fieldset> tag supports the Global Attributes and the Event Attributes.

How to style <fieldset> tag?

Common properties to alter the visual weight/emphasis/size of text in <fieldset> tag:

  • CSS font-style property sets the style of the font. normal | italic | oblique | initial | inherit.
  • CSS font-family property specifies a prioritized list of one or more font family names and/or generic family names for the selected element.
  • CSS font-size property sets the size of the font.
  • CSS font-weight property defines whether the font should be bold or thick.
  • CSS text-transform property controls text case and capitalization.
  • CSS text-decoration property specifies the decoration added to text, and is a shorthand property for text-decoration-line, text-decoration-color, text-decoration-style.

Coloring text in <fieldset> tag:

  • CSS color property describes the color of the text content and text decorations.
  • CSS background-color property sets the background color of an element.

Text layout styles for <fieldset> tag:

  • CSS text-indent property specifies the indentation of the first line in a text block.
  • CSS text-overflow property specifies how overflowed content that is not displayed should be signalled to the user.
  • CSS white-space property specifies how white-space inside an element is handled.
  • CSS word-break property specifies where the lines should be broken.

Other properties worth looking at for <fieldset> tag:

Browser support

chrome edge firefox safari opera

Practice Your Knowledge

What is the role of the HTML fieldset tag?

Quiz Time: Test Your Skills!

Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.

Do you find this helpful?