CSS Vertical Align

The CSS vertical align property is used to define the vertical alignment of an inline or table-cell box. It is the one of the self-explanatory property of CSS. It is not very easy property for beginners.

What it does

  1. It is applied to inline or inline-block elements.
  2. It affects the alignment of the element, not its content. (except table cells)
  3. When it applied to the table cells, it affect the cell contents, not the cell itself.

CSS Vertical Align Values

valuedescription
baselineIt aligns the baseline of element with the baseline of parent element. This is a default value.
lengthIt is used to increase or decrease length of the element by the specified length. negative values are also allowed.
%It is used to increase or decrease the element in a percent of the "line-height" property. negative values are allowed.
subIt aligns the element as if it was subscript.
superIt aligns the element as if it was superscript.
topIt aligns the top of the element with the top of the tallest element on the line.
bottomIt aligns the bottom of the element with the lowest element on the line.
text-topthe top of the element is aligned with the top of the parent element's font.
middlethe element is placed in the middle of the parent element.
text-bottomthe bottom of the element is aligned with the bottom of the parent element's font.
initialIt sets this property to Its default value.
inheritinherits this property from Its parent element.

CSS Vertical Align Example

Test it Now

Output:

Good Morning Friends This is an image with a default alignment.

Good Morning Friends This is an image with a text-top alignment.

Good Morning Friends This is an image with a text-bottom alignment.

Next TopicCSS White Space




Latest Courses