Blog IT

The <fieldset> tag is used to visually group some logically related fields in the <form> tag. In this tutorial, you will find some examples of using the <fieldset> tag and find out why we need this tag at all.

In the example below, we place the <fieldset> element in a <form> tag. In the <fieldset>, we add the <legend>, <input>, and <label> elements.

<!DOCTYPE html>
<html>
  <head>
    <title>How to Use the HTML <fieldset> Tag</title>
  </head>
  <body>
    <form>
      <fieldset>
        <legend>Book</legend>
        <input type="radio" name="book" value="html" id="book_html">
        <label for="book_html">HTML</label>
        <input type="radio" name="book" value="css" id="book_css">
        <label for="book_css">CSS</label>
        <input type="radio" name="book" value="javascript" id="book_javascript">
        <label for="book_javascript">Javascript</label>
      </fieldset>
    </form>
  </body>
</html>
How to Use the HTML <fieldset> Tag