|
HTML DOM verticalAlign Property
Complete Style Object Reference
Definition and Usage
The verticalAlign property sets the vertical alignment of content in an element box.
Syntax
|
Object.style.verticalAlign=value
|
Possible Values
| Value |
Description |
| baseline |
The element is placed on the baseline of the parent
element |
| sub |
Aligns the element as it was subscript |
| super |
Aligns the element as it was superscript |
| top |
The top of the element is aligned with the top of the
tallest element on the line |
| text-top |
The top of the element is aligned with the top of the
parent element's font |
| middle |
The element is placed in the middle of the parent
element |
| bottom |
The bottom of the element is aligned with the lowest
element on the line |
| text-bottom |
The bottom of the element is aligned with the bottom of
the parent element's font |
| length |
|
| % |
Aligns the element in a % value of the "line-height"
property. Negative values are allowed |
Example
The following example changes the vertical alignment of text in a table:
<html>
<head>
<script type="text/javascript">
function alignText()
{
document.getElementById("td1").style.verticalAlign="bottom";
}
</script>
</head>
<body>
<table border="1" height="100px">
<tr>
<td id="td1">
Some example text
</td>
</tr>
</table>
<br />
<input type="button" onclick="alignText()"
value="Align text" />
</body>
</html>
|
|
Complete Style Object Reference
 |
W3Schools' Online Certification Program
The perfect solution for professionals who need to balance work, family, and career building.
More than 3500 certificates already issued!
|
The HTML Certificate documents your knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
|