Code has been added to clipboard!

HTML fieldset Tag

Reading time 1 min
Published Mar 19, 2019
Updated Oct 1, 2019

HTML fieldset: Main Tips

  • The <fieldset> in HTML groups elements inside a <form> element.
  • The <legend> element adds a caption for the <fieldset> element. You need to place it inside the HTML <fieldset> element.

Use of fieldset

The HTML <fieldset> tag groups <form> elements. Normally, a box border is drawn around them.

Example
<form action="login" method="POST">
  <fieldset>
    <legend>Login Form:</legend>
    Username: <input type="text" name="user_name">
    Password: <input type="password" name="user_password">
    <input type="submit" value="Login">
  </fieldset>
</form>

Note: the box border provides some space for captions and creates better visual appearance for the grouped elements.

Attributes for fieldset

disabled

The disabled attribute turns off all the elements inside the <fieldset> element.

Example
<form action="login" method="POST">
  <fieldset disabled>
    <legend>Login Form:</legend>
    Username: <input type="text" name="user_name">
    Password: <input type="password" name="user_password">
    <input type="submit" value="Login">
  </fieldset>
</form>

form

The form attribute gets the values of the ID attributes of a <form> element, which will be a part of the <fieldset> in HTML.

Example
<form action="login" method="POST" id="user_form">
  <fieldset>
    <legend>Login Form:</legend>
    Username: <input type="text" name="user_name">
    Password: <input type="password" name="user_password">
    <input type="submit" value="Login">
  </fieldset>
</form>

<fieldset form="user_form">
  <legend>Other Details:</legend>
  Email ID: <input type="text" name="user_email">
  Phone Number: <input type="text" name="user_number">
</fieldset>

name

It defines the name for the grouped elements.

Example
<form action="login" method="POST" id="user_form">
  <fieldset name="login_form">
    <legend>Login Form:</legend>
    Username: <input type="text" name="user_name">
    Password: <input type="password" name="user_password">
    <input type="submit" value="Login">
  </fieldset>
</form>

Browser support

Chrome
All
Edge
All
Firefox
All
IE
All
Opera
All
Safari
All

Mobile browser support

Chrome
All
Firefox
All
Opera
All
Safari
All
Basics
Introduction
Syntax
Editors
Basic Examples
Head Section
<!DOCTYPE>
Tags and Elements
Semantic Elements
Tags Reference
Attributes
Comments
Block and Inline Elements
Forms
Form Elements
Input
Responsive Web Design
Inline Scripts
Uniform Resource Locator
Redirect
XHTML
Geolocation
Drag and Drop
Local Storage
Web Workers
Server-Sent Events
Character Encoding
Text Formatting
Quotation and Citation Elements
Headings
Paragraphs
Links
Tables
Lists
Symbols
Space
Tab
Styles
Computer Code
Layout
Classes
Colors
Images
iframes
Audio Player
Video Player
YouTube Videos
Multimedia
Canvas
SVG
<!-- -->
<a>
<abbr>
<acronym> DEPRECATED
<address>
<applet> DEPRECATED
<article>
<aside>
<audio>
<b>
<base>
<basefont> DEPRECATED
<bdi>
<bdo>
<big> DEPRECATED
<blink> DEPRECATED
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center> DEPRECATED
<cite>
<code>
<col>
<colgroup>
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<dir> DEPRECATED
<div>
<dl>
<dt>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<font> DEPRECATED
<footer>
<form>
<frame> DEPRECATED
<frameset> DEPRECATED
<h1> – <h6>
<head>
<header>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<keygen> DEPRECATED
<label>
<legend>
<li>
<link>
<main>
<map>
<mark>
<menu>
<menuitem> DEPRECATED
<meta>
<meter>
<nav>
<noframes> DEPRECATED
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike> DEPRECATED
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<tt> DEPRECATED
<u>
<ul>
<var>
<video>
<wbr>