Javascript examples for CSS Style Property:verticalAlign
Controls vertical alignment of the content in an element.
Value | Description |
---|---|
length | Align by the length. Negative values are allowed |
% | Align in a percent of the "line-height" property. Negative values are allowed |
baseline | Align along the baseline of the element. This is default |
sub | as if <sub> |
super | as if <sup> |
top | aligned with the top of the tallest element on the line |
text-top | aligned with the top of the parent element's font |
middle | aligned in the middle of the parent element |
bottom | aligned with the lowest element on the line |
text-bottom | aligned with the bottom of the parent element's font |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | baseline? |
Return Value: | A String, representing the vertical alignment of the content in an element |
CSS Version | CSS1 |
Set the vertical alignment of some text in a table to "bottom":
<!DOCTYPE html> <html> <head> <style> table {//from w ww. jav a 2s. c o m border: 1px solid black; height: 100px; } </style> </head> <body> <table> <tr> <td id="myTd" style="vertical-align:top;">Some example text</td> </tr> </table> <br> <button type="button" onclick="myFunction()">Return vertical alignment</button> <script> function myFunction() { document.getElementById("myTd").style.verticalAlign = 'bottom'; } </script> </body> </html>