[SOLVED]How to vertically align a table row

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

[SOLVED]How to vertically align a table row

Post by vigge89 »

I'm creating the layout for my new "community", and I'm currently at positioning the right side menu (number 2 on the image). But i've came across some problems. The question is: how can i vertically align number 2 to the top? on default, it positions itself in the middle of the row/col, and stays there ( :P ). I've succeded in doing this before, but i've forgot how i did it.

So, how do i make the content of the row/column appear on the top of it?
Are there any stylish ( ;) ) way to do it in CSS, and also, can it be done in normal HTML???

Also, zoom in to see the image properly ;)
White borders are the main layout table, and the black ones are for each "section"

Image

Edit: forgot the image ;)
Last edited by vigge89 on Wed Jan 14, 2004 9:03 am, edited 1 time in total.
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post by uberpolak »

The cell which contains the menu table should have the "valign" attribute set to "top." Like this:

Code: Select all

...
<td valign="top">
    <table>
     ...
    </table>
</td>
...
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You can also use CSS for this:

Code: Select all

<td style="vertical-align: top;">
    ....
</td>
Since the sites I work on very rarely want a middle alignment in table cells, I always set the following in my style sheet to force it to top alignment by default for all table cells (I also set horizontal alignment to left and a few other bits and bobs to override the default browser behaviours):

Code: Select all

TD &#123; vertical-align: top; &#125;
Mac
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

thanks, it's working now :D
Post Reply