vertical-align

  • Revision slug: CSS/vertical-align
  • Revision title: vertical-align
  • Revision id: 24617
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment 1 words removed

Revision Content

{{ CSSRef() }}

Summary

The vertical-align CSS property specifies the vertical alignment of an inline or table-cell element.

<style type="text/css"></style>
  • {{ Xref_cssinitial() }}: {{ Cssxref("baseline") }}
  • Applies to: inline elements and table cells
  • {{ Xref_cssinherited() }}: No
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}:

Syntax

vertical-align: baseline | sub | super | text-top | text-bottom | middle | top | bottom | <percentage> | <length> | {{ Cssxref("inherit") }}

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 {{ Cssxref("line-height") }} property

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.

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.

Examples

img {
	vertical-align: bottom;
}

Specifications

Browser compatibility

Browser lowest version
Internet Explorer 4.0
Firefox (Gecko) 1.0 (1.0)
Opera 4.0
Safari (WebKit) 1.0 (85)

See also

{{ Cssxref("line-height") }}, {{ Cssxref("text-align") }}, {{ Cssxref("margin") }} (auto)

{{ languages( { "de": "de/CSS/vertical-align", "fr": "fr/CSS/vertical-align", "pl": "pl/CSS/vertical-align" } ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code>vertical-align</code> <a href="/en/CSS" title="CSS">CSS</a> property specifies the vertical alignment of an inline or table-cell element.</p>
<nobr>
<style type="text/css"><![CDATA[.cssprop {
  display:table;
  padding: 0.4em;
  border-left:0.15em solid;
  background-color:#eeeeff
}
.cssprop li {
 display:table-row;
 padding: 3px;
 margin:0;
}
.cssprop li dfn {
  display:table-cell;
  padding: 0 5px;
  border-bottom: none;
  cursor:inherit;
}

]]></style>
<ul class="cssprop"> <li><dfn>{{ Xref_cssinitial() }}:</dfn> {{ Cssxref("baseline") }}</li> <li><dfn>Applies to:</dfn> inline elements and table cells</li> <li><dfn>{{ Xref_cssinherited() }}:</dfn> No</li> <li><dfn>Media:</dfn> {{ Xref_cssvisual() }}</li> <li><dfn>{{ Xref_csscomputed() }}:</dfn></li>
</ul>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<p><code>vertical-align:</code> <code>baseline</code> | <code>sub</code> | <code>super</code> | <code>text-top</code> | <code>text-bottom</code> | <code>middle</code> | <code>top</code> | <code>bottom</code> | &lt;percentage&gt; | <a href="/en/CSS/length" title="en/CSS/length">&lt;length&gt;</a> | {{ Cssxref("inherit") }}</p>
<h3 id="Values_.28for_inline_elements.29" name="Values_.28for_inline_elements.29">Values (for inline elements)</h3>
<p>Most of the values vertically align the element relative to its parent element:</p>
<dl> <dt>baseline </dt> <dd>Align the baseline of the element with the baseline of its parent.</dd> <dt>sub </dt> <dd>Align the baseline of the element with the subscript-baseline of its parent.</dd> <dt>super </dt> <dd>Align the baseline of the element with the superscript-baseline of its parent.</dd> <dt>text-top </dt> <dd>Align the top of the element with the top of the parent element's font.</dd> <dt>text-bottom </dt> <dd>Align the bottom of the element with the bottom of the parent element's font.</dd> <dt>middle </dt> <dd>Align the middle of the element with the middle of lowercase letters in the parent.</dd> <dt><a href="/en/CSS/length" title="en/CSS/length">&lt;length&gt;</a></dt> <dd>Align the baseline of the element at the given length above the baseline of its parent.</dd> <dt>&lt;percentage&gt; </dt> <dd>like &lt;length&gt; values, with the percentage being a percent of the {{ Cssxref("line-height") }} property</dd>
</dl>
<p>For elements that do not have a baseline, the bottom margin edge is used instead.</p>
<p>However, two values vertically align the element relative to the entire line rather than relative to its parent:</p>
<dl> <dt>top </dt> <dd>Align the top of the element and its descendants with the top of the entire line.</dd> <dt>bottom </dt> <dd>Align the bottom of the element and its descendants with the bottom of the entire line.</dd>
</dl>
<p>Negative values are allowed.</p>
<h3 id="Values_.28for_table_cells.29" name="Values_.28for_table_cells.29">Values (for table cells)</h3>
<dl> <dt>baseline (and sub, super, text-top, text-bottom, &lt;length&gt;, and &lt;percentage&gt;) </dt> <dd>Align the baseline of the cell with the baseline of all other cells in the row that are baseline-aligned.</dd> <dt>top</dt> <dd>Align the top padding edge of the cell with the top of the row.</dd> <dt>middle</dt> <dd>Center the padding box of the cell within the row.</dd> <dt>bottom</dt> <dd>Align the bottom padding edge of the cell with the bottom of the row.</dd>
</dl>
<p>Negative values are allowed.</p>
<h2 id="Examples" name="Examples">Examples</h2>
<pre>img {
	vertical-align: bottom;
}
</pre>
<h2 id="Specifications" name="Specifications">Specifications</h2>
<ul> <li><a class="external" href="http://www.w3.org/TR/CSS1#vertical-align">CSS 1</a></li> <li><a class="external" href="http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align">CSS 2.1</a></li>
</ul>
<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
<table class="standard-table"> <tbody> <tr> <th>Browser</th> <th>lowest version</th> </tr> <tr> <td>Internet Explorer</td> <td>4.0</td> </tr> <tr> <td>Firefox (Gecko)</td> <td>1.0 (1.0)</td> </tr> <tr> <td>Opera</td> <td>4.0</td> </tr> <tr> <td>Safari (WebKit)</td> <td>1.0 (85)</td> </tr> </tbody>
</table>
<h2 id="See_also" name="See_also">See also</h2>
<p>{{ Cssxref("line-height") }}, {{ Cssxref("text-align") }}, {{ Cssxref("margin") }} (<code>auto</code>)</p>
<p>{{ languages( { "de": "de/CSS/vertical-align", "fr": "fr/CSS/vertical-align", "pl": "pl/CSS/vertical-align" } ) }}</p></nobr>
Revert to this revision