CSS - vertical-align


Description:

The vertical-align property determines the alignment of text within a line, or within a table cell.

Possible Values:

  • baseline: The baseline of the element is aligned with the baseline of the parent element.
  • sub: The baseline of the element is lowered to the point appropriate for subscripted text.
  • super: The baseline of the element is raised to the point appropriate for superscripted text.
  • top: The top of the element's box is aligned with the top of the line box, in the context of inline content, or with the top of the table cell in the context of tables.
  • text-top: The top of the element's box is aligned with the top of the highest inline box in the line.
  • middle: The baseline of the element is aligned with the point defined by the baseline of the parent element plus half the x-height of the parent element's font, in the context of inline content.
  • bottom: The bottom of the element's box is aligned with the bottom of the line box, in the context of inline content, or with the bottom of the table cell in the context of tables.
  • text-bottom: The bottom of the element's box is aligned with the bottom of the lowest inline box in the line.
  • percentage: The baseline of the element is raised or lowered by the given percentage of the value for the property line-height.
  • length: The baseline of the element is raised or lowered by the given length value. Negative length values are permitted for this property. A length value of 0 for this property has the same effect as the value baseline.

Applies to:

inline-level elements and elements with a display of table-cell

DOM Syntax:

object.style.verticalAlign="baseline";

Example:

Here is the example:

<table style="height:200px; width:400px;border:1px solid red;">
<tr><td style="vertical-align:bottom;" >
<p>This will be aligned to bottom of the cell.</p>
</tr></td>
</table>
     

This will produce following result:

This will be aligned to bottom of the cell.





Spacer Bottom Left Corner ImageBottom Right Corner Image
Valid XHTML 1.0 Strict  Valid CSS! Check the accessibility of this site according to U.S. Section 508