Center Align content in Table Cells

To center align content in table cells using CSS, set the CSS text-align property to center for the table cells td.

The CSS code to set text-align property for the table cells is shown in the following.

td {
  text-align: center;
}

Examples

ADVERTISEMENT

1. Center align text in table cells

In the following example, we take a table with two columns, and three rows; and set the text alignment to center for the table cells.

index.html

Conclusion

In this CSS Tutorial, we learned how to use CSS text-align property to center align content in the table cells, with examples.