HTML vertically align content of table cell when there's image inside

John Smith picture John Smith · Nov 2, 2012 · Viewed 30.6k times · Source

Is there any way to make text vertically be aligned text Hello World! to middle of table cell without splitting into two cells?

<table border="1">
    <tr>
        <td valign="middle" style="vertical-align:middle;">
            Hello World! <img src="https://www.google.com/images/srpr/logo3w.png" border="1" />
        </td>
    </tr>
</table>

http://jsfiddle.net/U4Qs4/

Answer

user1534664 picture user1534664 · Nov 2, 2012

You need to vertically align the image, not the td element.