<fieldset> and <legend>
The <fieldset> element represents a set of form controls optionally grouped under a common name.
The common name of the group is provided by the first child <legend> element of the <fieldset> element.
Browser Support
Note: The following information about browser support is from the MDN Web Docs HTML Elements Reference.
For <fieldset>
All versions of all browsers.
For <legend>
- Desktop
- Chrome: All versions
- Edge: All versions
- Firefox: All versions
- Internet Explorer: 6 and later
- Opera: All versions
- Safari: All versions
- Mobile
- Android webview: All versions
- Chrome for Android: All versions
- Firefox for Android: 4 and later
- Opera for Android: Unknown
- Safari on iOS: All versions
- Samsung Internet: All versions
Default Browser Behavior
Content inside a <fieldset> element will be rendered as a block with a solid gray border.
Content inside a <legend> element will be rendered plainly, overlapping the top border of the parent <fieldset> element near its top-left corner.