Welcome to WebmasterWorld Guest from

Forum Moderators: not2easy

Message Too Old, No Replies

Vertical text align in table cell

Aligning text vertically in a table cell



2:34 pm on May 19, 2007 (gmt 0)

10+ Year Member

I've created a table and put a picture in each cell.

<td valign=top>
<img src="Image_one.jpg">
<td valign=top>
<img src="Image_two.jpg">

I can vertically align the text using the HTML code valign=top. And the problem is, if I do it that way, I have to write the same code in every <td> tag. And I'd like to do the same thing using CSS and align the text in all the table cells at once. But I don't know the CSS code for it. Help!

And a similar question, if I use photos instead of text, do I need a different code?


11:51 pm on May 19, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

td img{vertical-align:middle}
Will vertically align the inline elements which come after it (text image, span, etc.) centered to the image.


4:09 pm on May 20, 2007 (gmt 0)

10+ Year Member

Thanks X. That worked like a charm.

Featured Threads

Hot Threads This Week

Hot Threads This Month