CSS:vertical-align
From MDC
[edit] Summary
The vertical-align property specifies the vertical alignment of an inline or table-cell element.
- Initial value:
baseline - Applies to: inline elements and table cells
- Inherited: No
- Media:
visual - Computed value:
[edit] Syntax
vertical-align: baseline | sub | super | text-top | text-bottom | middle | top | bottom | <percentage> | <length> | inherit
[edit] Values (for inline elements)
Most of the values vertically align the element relative to its parent element:
- baseline
- Align the baseline of the element with the baseline of its parent.
- sub
- Align the baseline of the element with the subscript-baseline of its parent.
- super
- Align the baseline of the element with the superscript-baseline of its parent.
- text-top
- Align the top of the element with the top of the parent element's font.
- text-bottom
- Align the bottom of the element with the bottom of the parent element's font.
- middle
- Align the middle of the element with the middle of lowercase letters in the parent.
- <length>
- Align the baseline of the element at the given length above the baseline of its parent.
- <percentage>
- like <length> values, with the percentage being a percent of the
line-heightproperty
For elements that do not have a baseline, the bottom margin edge is used instead.
However, two values vertically align the element relative to the entire line rather than relative to its parent:
- top
- Align the top of the element and its descendants with the top of the entire line.
- bottom
- Align the bottom of the element and its descendants with the bottom of the entire line.
Negative values are allowed.
[edit] Values (for table cells)
- baseline (and sub, super, text-top, text-bottom, <length>, and <percentage>)
- Align the baseline of the cell with the baseline of all other cells in the row that are baseline-aligned.
- top
- Align the top padding edge of the cell with the top of the row.
- middle
- Center the padding box of the cell within the row.
- bottom
- Align the bottom padding edge of the cell with the bottom of the row.
Negative values are allowed.
[edit] Examples
img {
vertical-align: bottom;
}
[edit] Notes
[edit] Specifications
[edit] Browser compatibility
[edit] See also
line-height, text-align, margin (auto)