What is the easiest way to center a whole table in the middle of a page with HTML?
Asked
Active
Viewed 2,232 times
2 Answers
0
You cannot do it only with HTML
.
<center>
is only element that can do it, but is not preferred and is deprecated.
So you can use CSS
for this.
just put the parent element's position to be relative
and set horizontal margins of this element to be auto
.
example :
<div id="parent">
<table>
....
</table>
</div>
#parent {
position: relative;
}
table {
margin: 0px auto;
}

afzalex
- 8,598
- 2
- 34
- 61
-
The `#parent {position: relative;}` is unnecessary. So is the `px` after `0`. – Vivek Ghaisas Oct 03 '14 at 21:40