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 >
<!-- tbody tag starts -->
< table >
< tbody id = "tbodyID" align = "left" >
< tr >
< td >Shashank</ td >
< td >@shashankla</ td >
</ tr >
< tr >
< td >GeeksforGeeks</ td >
< td >@geeks</ td >
</ tr >
</ tbody >
<!-- tbody tag ends -->
</ 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 >
<!-- tbody tag starts -->
< table >
< tbody id = "tbodyID" align = "left" >
< tr >
< td >Shashank</ td >
< td >@shashankla</ td >
</ tr >
< tr >
< td >GeeksforGeeks</ td >
< td >@geeks</ td >
</ tr >
</ tbody >
<!-- tbody tag ends -->
</ 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