+ 1
Centering a table
How do you center an entire table in CSS
2 Respuestas
+ 1
To center an entire table in CSS, you can use the following code:
table {
margin: 0 auto;
}
This code sets the left and right margins of the table to "auto", which centers the table horizontally within its parent container.
Alternatively, you can also use the following code:
table {
display: block;
margin: 0 auto;
}
This code sets the display property of the table to "block", which allows it to have a width and height, and then centers it horizontally using the "margin" property as in the previous example.
Keep in mind that the parent container of the table must have a set width for the above code to work properly.
0
<table align=“center”>
…
</table>