verticalAlign style property
Specifies or returns how to align an element vertically.
Aligns content vertically, similarly to the deprecated vAlign property, but the 'sub' and 'super' values are only supported by text elements.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
CSS page for this property: vertical-align |
Possible values:
The type of this property is string.
One of the following values:
The alignment of the element's baseline depends on the value of the layoutFlow property. | |||||||
Default. Aligns the baseline of the element's text content with the baseline of the parent element. | |||||||
Aligns the bottom of the element's text content to the bottom of the object. | |||||||
The baseline of the element is aligned to this value above the baseline of the parent. For the supported length units, see the length page. | |||||||
The height is the specified percentage of the lineHeight property. | |||||||
Takes the value of this property from the computed style of the parent element. | |||||||
Aligns the vertical midpoint of the text content with the baseline plus half the x-height of the parent box. | |||||||
Aligns the baseline of the element's text content to the baseline of the parent subscript content. | |||||||
Aligns the baseline of the element's text content to the baseline of the parent superscript content. | |||||||
Aligns the bottom of the element's text content to the bottom of the parent element's font. | |||||||
Aligns the top of the element's text content to the top of the parent element's font. | |||||||
Aligns the top of the element's text content to the top of the object. |
Default: baseline.
Example HTML code 1:
This example illustrates the use of the vertical-align property:
|
||||
<body> <table border="2px"> <tr> <td style="vertical-align: middle;">middle aligned text</td> <td style="vertical-align: top;">top aligned text</td> <td width="40">A long text content to create a higher table cell</td> </tr> </table> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the verticalAlign property in JavaScript:
|
||||
<head> <script type="text/javascript"> function ChangeVertAlign (selectTag) { // Returns the index of the selected option var whichSelected = selectTag.selectedIndex; // Returns the text of the selected option var alignValue = selectTag.options[whichSelected].text; var tData = document.getElementById ("myTableData"); tData.style.verticalAlign = alignValue; } </script> </head> <body> <table border="2px"> <tr> <td id="myTableData">Aligned text</td> <td width="40">A long text content to create a higher table cell</td> </tr> </table> <br /> <select size="9" onchange="ChangeVertAlign (this);"> <option selected="selected" />auto <option />baseline <option />bottom <option />middle <option />sub <option />super <option />text-bottom <option />text-top <option />top </select> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
vertical-align (MSDN)
vertical-align (Mozilla Developer Center)
vertical-align (Safari Reference Library)
vertical-align (W3C)
vertical-align (Mozilla Developer Center)
vertical-align (Safari Reference Library)
vertical-align (W3C)
User Contributed Comments