Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    replacement for colspan?

    HI,

    using the following DOCTYPE, I get a validation error with colspan.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    What should be used instead of colspan where my table has to span, well, three columns.

    Edit:
    I have now removed it and get a validated page with the w3c and it displays as it should in IE6 ie7 and FF. So I suppose it must be OK.

    bazz
    Last edited by bazz; 01-22-2008 at 09:18 PM. Reason: update to message

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by bazz View Post
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    xhtml strict has col and colgroup:

    http://www.htmldog.com/reference/htmltags/colgroup/

    why do you use transitional?

    best regards

  • #3
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Thank you oesxyl.

    I'll look into that as well as making it strict.

    bazz

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,624
    Thanks
    6
    Thanked 1,001 Times in 974 Posts
    Quote Originally Posted by oesxyl View Post
    xhtml strict has col and colgroup
    Col and colgroup is not only present in strict XHTML, it has been around in HTML 4 as well (and more so in “transitional”) but that’s not the point. The point is that col and colgroup are no replacement for colspan as the former two are HTML elements while the latter one is an attribute that is applied to table cells (e.g. <td colspan="2"></td>) to combine (merge) more than one cell.

    For example:
    Code:
    <table>
      <tr>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td colspan="2"></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
      </tr>
    </table>
    This creates a table with three rows and two columns with the two columns in the middle being merged to form one colum that spans over two. Be aware that the number of table cells must match, i.e. we can’t have a colspan of 2 plus another table cell in the same row (note that I removed the second cell in the above example as two cells are merged to one), or a colspan of 3 when there are only two cells to merge.
    This shouldn’t throw up any HTML error in any version.

    Besides that, strict is still the doctype you should use.

  • #5
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Aha have I had a corrupted learning experience from about 5 yrs ago??

    I thought that colspan "2" should be applied to the table rather than the <td>

    I shall look up your code example as well as w3schools (again) to remind me of tables alyout.


    o yeh and I shall try to integrate the strict doctype.
    Thank you

    bazz


  •  

    Posting Permissions

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