Sometimes, we want to center the contents of an HTML table with CSS.
In this article, we’ll look at how to center the contents of an HTML table with CSS.
How to center the contents of an HTML table with CSS?
To center the contents of an HTML table with CSS, we use the text-align
and vertical-align
properties.
For instance, we write
td {
text-align: center;
vertical-align: middle;
}
to center text horizontally with text-align: center;
.
And we vertically center text with vertical-align: middle;
.
Conclusion
To center the contents of an HTML table with CSS, we use the text-align
and vertical-align
properties.