I\'ve been trying to align an image to the center of the table td. It worked with setting margin-left to a specific value but it also increased the size of td too and that isn\'
<table style="width:100%;">
<tbody ><tr><td align="center">
<img src="axe.JPG" />
</td>
</tr>
</tbody>
</table>
or
td
{
text-align:center;
}
in the CSS file
Another option is the use <th>
instead of <td>
. <th>
defaults to center; <td>
defaults to left.
Simple way to do it for html5 in css:
td img{
display: block;
margin-left: auto;
margin-right: auto;
}
Worked for me perfectly.