The <legend> tag is used to define the title for the child contents. The legend elements are the parent element. This tag is used to define the caption for the <fieldset> element.
The <legend> align attribute in HTML is used to specify the alignment of the caption in a <fieldset> element. The left and right alignment of <legend> element are supported by major browsers except Opera 12 and earlier versions. The bottom alignment are not supported by any browsers.
We can use CSS to align <legend> tag element to center. The CSS margin-left property will play the vital role here to center the legend element.
Below example implements the above approach:
- Differences between HTML <center> Tag and CSS "text-align: center;" Property
- How to Align Navbar Items to Center using Bootstrap 4 ?
- How to vertically and horizontally align flexbox to center ?
- How to Align modal content box to center of any screen?
- How to target all Font Awesome icons and align them center?
- How to vertically center text with CSS?
- CSS | text-align Property
- CSS | text-align-last Property
- How to Vertically Align Text Next to an Image using CSS ?
- How to align Placeholder Text in HTML ?
- How to align button to right side of text box in Bootstrap?
- How to vertically align text inside a flexbox using CSS?
- Text Animation with changing the color of the text using HTML & CSS
- How to center a div within another div?
- CSS | Align
- How to horizontally center a div using CSS?
- HTML | center Tag
- p5.js | center() Function
- CSS | align-self Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.