Sometimes, we want to center image in table td in CSS.
In this article, we’ll look at how to center image in table td in CSS.
How to center image in table td in CSS?
To center image in table td in CSS, we set the margins to auto.
For instance, we write
td img {
display: block;
margin-left: auto;
margin-right: auto;
}
to set the img elements in td elements to have margin-left and margin-right set to auto to center the img element in the td element.
Conclusion
To center image in table td in CSS, we set the margins to auto.