HTML DOM TBody align Property
Last Updated :
22 Feb, 2022
The HTML DOM TBody align property is used to set or return the horizontal alignment of the content within the <tbody> element. It is not supported by HTML5.
Syntax:
-
It returns the align property.
tbodyobject.align
-
It sets the align property.
tbodyObject.align = "left | right | center | justify | clear"
Property values:
- left: It sets the text to left-align.
- right: It sets the text to right-align.
- center: It sets the text to center-align. It is a default value.
- justify: It stretches the text of paragraph to set the width of all lines equal.
- char: It sets the text-align to a specific character.
Return Values: It returns a string value that represents the alignment of the
element.
Example: Below HTML Code illustrates how to returns the TBody align property.
HTML
<!DOCTYPE html>
< html >
< head >
< style >
table,
th,
td {
border: 1px solid green;
}
</ style >
</ head >
< body >
< center >
< h1 >
GeeksforGeeks
</ h1 >
< h2 >HTML DOM TBody align Property </ h2 >
< table >
< tbody id = "tbodyID" align = "left" >
< tr >
< td >Shashank</ td >
< td >@shashankla</ td >
</ tr >
< tr >
< td >GeeksforGeeks</ td >
< td >@geeks</ td >
</ tr >
</ tbody >
</ table >
< p >
Click on the button to return
the alignment of the TBody element
</ p >
< button onclick = "btnclick()" >
Click Here!
</ button >
< p id = "paraID" ></ p >
</ center >
< script >
function btnclick() {
var tbody = document
.getElementById("tbodyID").align;
document.getElementById("paraID")
.innerHTML = tbody;
}
</ script >
</ body >
</ html >
|
Output:
Example 2: Below HTML code illustrates how to set the TBody align property.
HTML
<!DOCTYPE html>
< html >
< head >
< style >
table,
th,
td {
border: 1px solid green;
}
</ style >
</ head >
< body >
< center >
< h1 >
GeeksforGeeks
</ h1 >
< h2 >HTML DOM TBody align Property </ h2 >
< table >
< tbody id = "tbodyID" align = "left" >
< tr >
< td >Shashank</ td >
< td >@shashankla</ td >
</ tr >
< tr >
< td >GeeksforGeeks</ td >
< td >@geeks</ td >
</ tr >
</ tbody >
</ table >
< p >
Click on the button to set the
alignment of the TBody element
</ p >
< button onclick = "btnclick()" >
Click Here!
</ button >
< p id = "paraID" ></ p >
</ center >
< script >
function btnclick() {
var tbody = document.getElementById("tbodyID")
.align = "right";
document.getElementById("paraID")
.innerHTML = tbody;
}
</ script >
</ body >
</ html >
|
Output:
Supported Browsers:
- Google Chrome
- Internet Explorer
- Firefox
- Safari
- Opera
Share your thoughts in the comments
Please Login to comment...
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy
Please go through our recently updated Improvement Guidelines before submitting any improvements.
This article is being improved by another user right now. You can suggest the changes for now and it will be under the article's discussion tab.
You will be notified via email once the article is available for improvement.
Thank you for your valuable feedback!
Please go through our recently updated Improvement Guidelines before submitting any improvements.
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.