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 modal content box to center of any screen?
- How to Align Navbar Items to Center using Bootstrap 4 ?
- How to vertically and horizontally align flexbox to 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 vertically align text inside a flexbox using CSS?
- How to align button to right side of text box in Bootstrap?
- How to center a div within another div?
- HTML | center Tag
- p5.js | center() Function
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.