The Legend align Property in HTML DOM is used to set or return the value of the align attribute of a <legend> Element.
Sntax:
- It returns a legend align Property.
Legendobject.align;
- It sets the Legend align Property.
Legendobject.align="left|right|top|bottom"
Property values: This poperty accepts four parameter as mentioned above and described below:
- left: It sets the caption to the left of element.
- right: It sets the caption to the right of element.
- top: It sets the caption to the top of element.
- bottom: It sets the caption to the bottom of element.
Example 1: This Example returns a Legend align Property.
<!DOCTYPE html> <html> <head> <title>DOM Legend align Property</title> <style> form { width: 70%; } label { display: inline-block; float: left; clear: left; width: 90px; margin: 5px; text-align: left; } input[type="text"] { width: 250px; margin: 5px 0px; } .gfg { font-size: 40px; color: green; font-weight: bold; } </style> </head> <body> <div class="gfg">GeeksforGeeks</div> <h2>DOM Legend align Property</h2> <form id="myGeeks"> <fieldset> <!-- Assigning legend id --> <legend id="GFG" align="left">STUDENT::</legend> <label>Name:</label> <input type="text"> <br> <label>Email:</label> <input type="text"> <br> <label>Date of birth:</label> <input type="text"> <br> <label>Address:</label> <input type="text"> <br> <label>Enroll No:</label> <input type="text"> </fieldset> </form> <br> <button onclick="myGeeks()">Submit</button> <p id="sudo" style="font-size:25px;"></p> <script> function myGeeks() { // Accessing legend tag var g = document.getElementById("GFG").align; document.getElementById( "sudo").innerHTML = g; } </script> </body> </html> |
Output:
- Before Clicking On Button:

- After Clicking On Button:

Example 2: This Example sets the Legend align Property.
<!DOCTYPE html> <html> <head> <title>DOM Legend align Property</title> <style> form { width: 70%; } label { display: inline-block; float: left; clear: left; width: 90px; margin: 5px; text-align: left; } input[type="text"] { width: 250px; margin: 5px 0px; } .gfg { font-size: 40px; color: green; font-weight: bold; } </style> </head> <body> <div class="gfg">GeeksforGeeks</div> <h2>DOM Legend align Property</h2> <form id="myGeeks"> <fieldset> <!-- Assigning legend id --> <legend id="GFG" align="left">STUDENT::</legend> <label>Name:</label> <input type="text"> <br> <label>Email:</label> <input type="text"> <br> <label>Date of birth:</label> <input type="text"> <br> <label>Address:</label> <input type="text"> <br> <label>Enroll No:</label> <input type="text"> </fieldset> </form> <br> <button onclick="myGeeks()">Submit</button> <p id="sudo" style="font-size:25px;"></p> <script> function myGeeks() { // Accessing legend tag var g = document.getElementById("GFG").align = "right"; document.getElementById( "sudo").innerHTML = "The value of the align attribute was changed to " + g; } </script> </body> </html> |
Output:
- Before Clicking On Button:

- After Clicking On Button:

Supported Browsers: The browsers supported by HTML DOM Legend align Property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | <legend> align Attribute
- HTML | DOM Legend form Property
- How to Align <legend> Tag Text to Center ?
- HTML | DOM HR align Property
- HTML | DOM Div align Property
- HTML | DOM Object align Property
- HTML | DOM caption align Property
- HTML | DOM TableRow align Property
- HTML | DOM Paragraph align Property
- Differences between HTML <center> Tag and CSS "text-align: center;" Property
- HTML <legend> Tag
- HTML | DOM Legend Object
- HTML | <legend> form Attribute
- CSS | align-self Property
- CSS | text-align-last Property
- CSS | align-items Property
- CSS | vertical-align Property
- CSS | text-align Property
- CSS | align-content property
- HTML | <hr> align Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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.
Improved By : shubham_singh


