
- HTML Home
- HTML Roadmap
- HTML Introduction
- HTML History & Evolution
- HTML Editors
- HTML Basic Tags
- HTML Elements
- HTML Attributes
- HTML Headings
- HTML Paragraphs
- HTML Fonts
- HTML Blocks
- HTML Style Sheet
- HTML Formatting
- HTML Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Frames
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Code Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Table Headers & Captions
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB & RGBA Colors
- HTML - HEX Colors
- HTML - HSL & HSLA Colors
- HTML - HSL Color Picker
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - Document Object Model (DOM)
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Character Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - <fieldset> Tag
HTML <fieldset> Tag
The HTML <fieldset> tag is used to group several controls and labels within a web form. This element, introduced in HTML5, serves as a container for grouping form elements. The HTML <legend> tag can be used to label that group as well.
Syntax
Following is the syntax of <fieldset> tag −
<fieldset> ... </fieldset>
Attributes
The HTML <fieldset> tag supports both Global and Event attributes. It also accepts some specific attributes which are listed bellow.
Attribute | Value | Description |
---|---|---|
disabled | disabled | Specifies that a group of related form elements is disabled. |
form | form_id | Specifies forms that belong to the fieldset. |
name | text | Specifies a name for fieldset. |
Example: Creating Fieldset
In the following program, we use the HTML <fieldset> tag to group several controls within a web form. However, since it is not used within a form, it will display only as an anonymous box.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML Fieldset</title> </head> <body> <strong>HTML fielset Tag</strong> <br> <br> <!-- Create a fieldset --> <fieldset> <input type="radio" id='english'> <label for="english">English</label> <input type="radio" id='english'> <label for="english">Hindi</label> <input type="radio" id='english'> <label for="english">Telegu</label> </fieldset> </body> </html>
Example: Form Fieldset
In this program, the <fieldset> element is used with the <form> element to group several controls within a web form. It provides a container for the form contents.
<!DOCTYPE html> <html> <head> <title>HTML Fieldset</title> <style> input{ width: 40%; } textarea { width: 90%; } </style> </head> <body> <form> <fieldset> <label>First Name</label> <input type="text" name="FirstName"/> <br><br> <label>Last Name</label> <input type="text" name="LastName"/> </fieldset> <br> <fieldset> <label>Email id</label> <input type="email" name="email"/> <br><br> <label>Enter your password</label> <input type="password" name="password"/> <br><br> <label>Confirm your password</label> <input type="password"name="confirmPass"/> </fieldset> <br> <fieldset> <label>Address</label> <br> <textarea name="address"></textarea> </fieldset> <br> <button>Submit</button> </form> </body> </html>
Example: Styling Fieldset
In the following example we will style our previously created <fieldset> by modifying its width, border color, and other properties using CSS.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML Fieldset</title> <style> fieldset{ border-color: gray; width: 250px; padding-left: 25px; } </style> </head> <body> <strong>HTML fielset Tag</strong> <br> <br> <!-- Create a fieldset --> <fieldset> <input type="radio" id='english'> <label for="english">English</label> <input type="radio" id='english'> <label for="english">Hindi</label> <input type="radio" id='english'> <label for="english">Telegu</label> </fieldset> </body> </html>
Example: Grouping and Styling
In this example, we use the <fieldset> element to group several controls within the form. We then use CSS to style the fieldset element.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML Fieldset</title> <style> fieldset { width: 50%; height: 100px; color: rgb(43, 255, 0); } legend { width: 150px; height: 50px; background-color: green; color: white; background-color: blueviolet; } </style> </head> <body> <!--create a fieldset--> <p>HTML fieldset Tag</p> <fieldset> <legend>Choose your fav languages</legend> <input type="checkbox"> <label for="">HTML</label> <input type="checkbox"> <label for="">JavaScript</label> <input type="checkbox"> <label for="">Java</label> </fieldset> </body> </html>
Example: Disabled Fieldset
Let's look at the following program, where we use the disabled attribute within the <fieldset> element to disable it.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML fieldset Tag</title> <style> fieldset { width: 70%; height: 100px; color: rgb(0, 195, 255); } </style> </head> <body> <!--create a fieldset--> <p>HTML fieldset Tag</p> <form> <fieldset disabled> <legend>Disabled login fieldset</legend> <label for="">Username</label> <input type="text" placeholder="Username"> <br> <br> <label for="">Password</label> <input type="password" placeholder="Password"> </fieldset> </form> </body> </html>
Supported Browsers
Tag | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
fieldset | Yes | Yes | Yes | Yes | Yes |