align="center"
.
<table align="center">
...
</table>
However, that method of centering a table is deprecated in
HTML5.
To center a table, which is a block-level element, in HTML5 using
a Cascading Style Sheets method, you can use
a style that includes margin-left: auto; margin-right: auto;
as shown below.
<table style="margin-left: auto; margin-right: auto;">
...
</table>
E.g:
Number | English | Spanish | French |
---|---|---|---|
1 | January | enero | janvier |
2 | February | febrero | février |
3 | March | marzo | mars |
4 | April | abril | avril |
5 | May | mayo | mai |
6 | June | junio | juin |
7 | July | julio | juillet |
8 | August | agosto | août |
9 | September | septiembre | septembre |
10 | October | octubre | octobre |
11 | November | noviembre | novembre |
12 | December | diciembre | décembre |
Or you can include the following style information in the HEAD section of the webpage:
<style type="text/css">
table.centered { margin-left: auto; margin-right: auto; }
</style>
You can then set the "class" for any tables that you wish to be centered on a webpage as shown below.
<table class="centered">
...
</table>
If you wish to have your table occupy a certain width on the page, but be centered, you can use code similar to the following:
<table style="width: 50%; margin-left: 25; margin-right: 25%;">
...
</table>
E.g.:
Number | English | Spanish | French |
---|---|---|---|
1 | January | enero | janvier |
2 | February | febrero | février |
3 | March | marzo | mars |
4 | April | abril | avril |
5 | May | mayo | mai |
6 | June | junio | juin |
7 | July | julio | juillet |
8 | August | agosto | août |
9 | September | septiembre | septembre |
10 | October | octubre | octobre |
11 | November | noviembre | novembre |
12 | December | diciembre | décembre |