SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    eez
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is this definition of a table legal?

    Hi!

    Is this definition of a html table valid xhtml?

    <table>
    <tr>
    <td></td>
    <td></td>
    <td></td>
    </tr>
    <tr>
    <td></td>
    <td></td>
    </tr>
    </table>


    In short, is it legal to have more TDs in one TR than in another?

    Thanks

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,449
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    No. You have to have an equal number of columns in each row. Otherwise it isn't valid in any version of HTML. You will need to use 'colspan' to make one table cell stretch to the width of two table cells to be valid.

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, you can, but you should normally use colspan to specify that one cell should span more than one column.

    If you want an empty (unused) cell in one row, just add an empty cell (<td></td>).

    The example you posted is legal; the omitted cell in the second row will be implied, but it seems unsemantic. There should either be a column span or an explicit empty cell, IMHO.
    Birnam wood is come to Dunsinane

  4. #4
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    Temecula, CA
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    colspan and rowspan -- they're both great. Start here, but please, ignore the improper unclosed tr and td tags - bad form!

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    It's not improper; that's valid HTML the way it used to be written back then. But I agree that it's bad form nowadays.
    Birnam wood is come to Dunsinane

  6. #6
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by stymiee
    No. You have to have an equal number of columns in each row. Otherwise it isn't valid in any version of HTML.
    I can't find such conformance requirements in any version of HTML. Could you give me a pointer?
    Simon Pieters


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •