HTML table td align

For aligning text horizontally, use text-align CSS property.

For aligning vertically, use the vertical-align CSS property.

Example:

table.mytable td
{
  text-align:left;
  vertical-align: top;
}

table.mytable td.numbers
{
  text-align:center;
  vertical-align:middle;
}

table td align example

Horizontal text align values

Horizontal text align values

The text-align CSS attribute takes these values: left, center and right. The other supported values are: justify – stretch the lines to fit to the available width (like a newspaper column) and start and end.

There are languages that are written right to left rather than left to right. When you take that in to consideration, aligning left or right does not make sense. So two more values are added in CSS3 that is start and end.

Vertical text align values

vertical-align can be: top, middle or bottom. In addition, there is a baseline value that aligns the base line of the first line in the cell. baseline is the default value.

HTML table td vertical-align

Demo

Click Edit and then try changing the align values.

22934

Read More

HTML table tutorial and reference

Close

Copy and paste this code to display the image on your site

Copied!