verticalAlign Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:verticalAlign


Controls vertical alignment of the content in an element.

Property Values

Value Description
length Align by the length. Negative values are allowed
% Align in a percent of the "line-height" property. Negative values are allowed
baselineAlign along the baseline of the element. This is default
sub as if <sub>
super as if <sup>
top aligned with the top of the tallest element on the line
text-topaligned with the top of the parent element's font
middle aligned in the middle of the parent element
bottom aligned with the lowest element on the line
text-bottom aligned with the bottom of the parent element's font
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Technical Details

Item Value
Default Value: baseline?
Return Value: A String, representing the vertical alignment of the content in an element
CSS VersionCSS1

Set the vertical alignment of some text in a table to "bottom":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
table {//from w ww. jav  a  2s.  c o  m
    border: 1px solid black;
    height: 100px;

    <td id="myTd" style="vertical-align:top;">Some example text</td>

<button type="button" onclick="myFunction()">Return vertical alignment</button>

function myFunction() {
    document.getElementById("myTd").style.verticalAlign = 'bottom';


Related Tutorials