HTML legend tag is used to show title or captions for the fieldset elements.
This makes form elements much easier for the user to understand.
Syntax
1 |
<legend>Enter some legend text here</legend> |
1 2 3 4 5 6 7 8 9 |
<form> <fieldset> <legend>Person gender details</legend> <input type="radio" name="gender" value="male"/>Male <input type="radio" name="gender" value="female"/>Female <input type="radio" name="gender" value="others"/>Others </legend> </fieldset> </form> |
Output
List of HTML legend tag attributes
Sr. No. | Attribute options | Description |
---|---|---|
1 | align | This option used to align text to the specified directions. The values for this are left, center, right, top and center. |
Resources and References
1. W3C Specification.
2. HTML living standard
3. W3C project using Github