Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS vertical-align property

CSS vertical-align property

Example

Vertically align an image:

img

{

vertical-align:

text-top

;

}

Try it »


Property definition and usage

The vertical-align property sets the vertical alignment of an element.

This property defines the vertical alignment of an inline element's baseline relative to the baseline of the line it is in. Negative length and percentage values are allowed, which lower the element rather than raise it. In table cells, this property sets the alignment of the cell content within the cell box.

Default value: baseline
Inherited: no
Version: CSS1
JavaScript syntax: object.style.verticalAlign="bottom"

Browser support

The numbers in the table indicate the first browser version that supports this property.

property
vertical-align 1.0 4.0 1.0 1.0 4.0

Attribute values

Value Description
baseline Default. The element is placed on the parent element's baseline.
sub Vertically aligns the text as subscript.
super Vertically align the text as superscript
top Align the top of the element with the top of the tallest element in the line
text-top Align the top of the element with the top of the parent element's font
middle Place this element in the middle of the parent element.
bottom Align the bottom of the element and its descendants with the bottom of the entire line.
text-bottom Aligns the bottom of the element with the bottom of the parent element's font.
length Raise or lower the element by the specified height, which may be negative.
% Align this element using a percentage of the "line-height" property. Negative values are allowed.
inherit Specifies that the vertical-align property should be inherited from the parent element.

Related Articles

CSS Tutorial: CSS Text