W3Schools.com

tr vAlign Property

tr Object Reference tr Object

Definition and Usage

The vAlign property sets or returns the vertical alignment of the content within a table row.

Syntax

Set the vAlign property:

trObject.vAlign="baseline|bottom|middle|top"

Return the vAlign property:

trObject.vAlign

Value Description
baseline Content is aligned to the baseline. The baseline is the "imaginary line" which most letters "sit" on, in a line of text. The baseline value sets the row so that all the table data share the same baseline. Often this has the same effect as the bottom value. However, if the fonts are in different sizes, baseline looks better.
bottom Content is aligned to the bottom
middle Content is aligned to the middle. This is default
top Content is aligned to the top


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The vAlign property is supported in all major browsers.


Example

Example

Change the vertical alignment of the content within a table row:

<html>
<head>
<script type="text/javascript">
function displayResult()
{
document.getElementById('tr2').vAlign="top";
}
</script>
</head>
<body>

<table width="50%" border="1">
  <tr id="tr1">
    <th>Firstname</th>
    <th>Lastname</th>
    <th>Text</th>
  </tr>
  <tr id="tr2">
    <td>Peter</td>
    <td>Griffin</td>
    <td>Hello my name is Peter Griffin.
    I need a long text for this example.
    I need a long text for this example.</td>
  </tr>
</table>
<br />
<button type="button" onclick="displayResult()">Top-align content</button>

</body>
</html>

Try it yourself »


tr Object Reference tr Object

W3Schools Certification

W3Schools' Online Certification

The perfect solution for professionals who need to balance work, family, and career building.

More than 10 000 certificates already issued!

Get Your Certificate »

The HTML Certificate documents your knowledge of HTML.

The CSS Certificate documents your knowledge of advanced CSS.

The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.

The jQuery Certificate documents your knowledge of jQuery.

The XML Certificate documents your knowledge of XML, XML DOM and XSLT.

The ASP Certificate documents your knowledge of ASP, SQL, and ADO.

The PHP Certificate documents your knowledge of PHP and SQL (MySQL).

WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
Download XML Editor
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE