Isaac Lubow Isaac Lubow -4 years ago 53
HTML Question

What's the simplest way to center an image vertically within a line of text?

Presently I use:

<table cellpadding="0" cellspacing="0">
<tr><td><a href="cv.pdf" target="_blank">
<img src="graphics/pdf.gif" width="24" height="24" /></a></td>
<td width="10px"></td> <!--that just spaces the image from the text-->
<td>
<a href="cv.pdf" target="_blank"><em>Download CV.</em></a>
</td></tr>
</table>


Pretty clunky but renders perfectly. Is there any better way to do it?

Answer Source

Set the following CSS property on your image:

vertical-align: middle;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download