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 vertically and horizontally align flexbox to center ?
- How to Align modal content box to center of any screen?
- How to Align Navbar Items to Center using Bootstrap 4 ?
- How to target all Font Awesome icons and align them center?
- How to align a logo image to center of navigation bar using HTML and CSS ?
- Difference between align-content and align-items
- HTML | center Tag
- How to vertically center text with CSS?
- How to place table text into center using Bootstrap?
- CSS | text-align Property
- How to align Placeholder Text in HTML ?
- CSS | text-align-last Property
- How to vertically align text inside a flexbox using CSS?
- How to align button to right side of text box in Bootstrap?
- How to Vertically Align Text Next to an Image using CSS ?
- How to align text in CSS where both columns are straight?
- What purpose does a <script> tag serve inside of a <noscript> tag?
- Difference between <article> tag and <section> tag
- Why <big> tag is not in HTML5 while <small> tag exists ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.