homepage Welcome to WebmasterWorld Guest from 107.20.25.215
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

    
Vertical text align in table cell
Aligning text vertically in a table cell
Adam5000




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

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

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

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?

 

Xapti




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

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

Adam5000




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

Thanks X. That worked like a charm.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved