Style verticalAlign property

Definition and usage

verticalAlign Sets or returns the vertical alignment of the content within an element.

See also:

CSS Tutorial:CSS κείμενο

CSS Reference Manual:vertical-align property

Instance

Example 1

Sets the vertical alignment of some text in the table to "bottom":

document.getElementById("myTd").style.verticalAlign = "bottom";

Try it yourself

Example 2

Returns the vertical alignment of the <td> element:

alert(document.getElementById("myTd").style.verticalAlign);

Try it yourself

Syntax

Return the verticalAlign property:

object.style.verticalAlign

Set the verticalAlign property:

object.style.verticalAlign = value

Property value

Value Description
length Raises or lowers the element by a specified length. Negative values are allowed.
% Raises or lowers the element by a percentage of the "line-height" property. Negative values are allowed.
baseline Aligns the baseline of the element with the baseline of the parent element. Default.
sub Aligns the element as an subscript.
super Aligns the element as a superscript.
top The top of the element aligns with the top of the highest element in the line.
text-top The top of the element aligns with the font top of the parent element.
middle The element is placed in the middle of the parent element.
bottom The bottom of the element aligns with the lowest element in the line.
text-bottom The bottom of the element aligns with the font bottom of the parent element.
initial Sets this property to its default value. See also: initial
inherit Inherits this property from its parent element. See also: inherit

Technical details

Default value: baseline
Return value: 字符串,表示元素中内容的垂直对齐方式。
Έκδοση CSS: CSS1

Υποστήριξη Περιηγητή

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Υποστήριξη Υποστήριξη Υποστήριξη Υποστήριξη Υποστήριξη