'Center-align a HTML table
On a page I'm working on at the moment, I can't seem to be able to center a table with an image in the first row and two columns of text below it (the two columns shouldn't be more than the image's width) Here's the page : http://www.puzzles-et-jeux.com/fr/page/minipuzzles.html I spent a lot of time trying to solve this. I would like to keep it in HTML because I have to rush and also because I have to create 20 pages of the sort with different widths /+ layouts for each image.
Solution 1:[1]
table
{
margin-left: auto;
margin-right: auto;
}
This will definitely work. Cheers
Solution 2:[2]
Try this -
<table align="center" style="margin: 0px auto;"></table>
Solution 3:[3]
Give it a class of center
then on CSS
.center {
margin-left: auto;
margin-right: auto;
}
Solution 4:[4]
margin-left: auto;
margin-right: auto;
You could adjust it depending on the screen size
Solution 5:[5]
<table align="center"></table>
This works for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Talha Daniyal |
| Solution 2 | Avinash T. |
| Solution 3 | ephantus okumu |
| Solution 4 | Gabriel soft |
| Solution 5 | alhelal |
