Sometimes, we want to center a checkbox in a table cell with CSS.
In this article, we’ll look at how to center a checkbox in a table cell with CSS.
How to center a checkbox in a table cell with CSS?
To center a checkbox in a table cell with CSS, we use flexbox.
For instance, we write
#table-id td:nth-child(1) {
display: flex;
justify-content: center;
}
to make the first td element a flex container with display: flex;
.
Then we center its contents horizontally with justify-content: center;
.
Conclusion
To center a checkbox in a table cell with CSS, we use flexbox.