Vertical align

Discussion in 'CSS' started by jet22, Sep 17, 2008.

  1. #1
    Hey.

    I'm designing a website and I'm having some trouble aligning some text.
    The text is placed inside a table, and automatically, it is positioned in the middle of the table. I want the text to be placed in the top of the table.
    I've tried the vertical-align css function, but I can't seem to get it to work. Of course I could make a lot of   underneath the text, but does anybody know how to do this in a nicer way?

    Thanks :)
     
    jet22, Sep 17, 2008 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    You really should show at least a minimal test case that shows what you've done, both the html and the css.

    Without knowing about any mitigating circumstance, I can only suggest
    td {vertical-align: top;}
    Code (markup):
    cheers,

    gary
     
    kk5st, Sep 17, 2008 IP
  3. rikun

    rikun Peon

    Messages:
    85
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If it's in a table, place valign="top" in the <td> tag. i.e. <td valign="top">

    I hope your not using tables to design the layout of your site though. If you are, use divs instead.
     
    rikun, Sep 17, 2008 IP
  4. deniseG

    deniseG Peon

    Messages:
    159
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Table etc.. will look like this
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
    <td width="60%" valign="top"> or whatever % you choose

    <p align="left"> or <div align="left">TEXT TEXT TEXT etc......

    then closing tags
     
    deniseG, Sep 17, 2008 IP
  5. jet22

    jet22 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Great, thanks guys.
    I've made it work now. I had assigned the vertical-align function to a class instead of the td tag. Thats what I did wrong. Thanks again :)
     
    jet22, Sep 17, 2008 IP
  6. lui2603

    lui2603 Peon

    Messages:
    729
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You can also vertical align in other elements by using:
    display: table-cell;
    vertical-align: middle;
     
    lui2603, Sep 18, 2008 IP
  7. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #7
    You could if you don't have any users with IE. IE<8 does not support any of the table group values of the display property.

    cheers,

    gary
     
    kk5st, Sep 18, 2008 IP
  8. mypsdtohtml

    mypsdtohtml Guest

    Messages:
    96
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    XHTML CSS without tables is much better than tables. Tableless design are W3C Compliant and you can change this kind of things.
     
    mypsdtohtml, Sep 19, 2008 IP