Center image in table td in CSS
Center a div inside td
using margin
, the trick is to make the div
width the same as the image width.
<td>
<div style="margin: 0 auto; width: 130px">
<img src="me.jpg" alt="me" style="width: 130px" />
</div>
</td>
Simple way to do it for html5 in css:
td img{
display: block;
margin-left: auto;
margin-right: auto;
}
Worked for me perfectly.
<td align="center">
or via css, which is the preferred method any more...
<td style="text-align: center;">