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 7 of 7
  1. #1
    New Coder
    Join Date
    Mar 2005
    Location
    France, Bordeaux
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    colspan="all" could be colspan="100"?

    Well at first it look like a dumb question but anyway, I'll go for it.

    We often want to have a cell in a table surrounding all other columns in width (or height), regardless of the number of those columns. In theory the consequent colspan has to match exactly the number of columns you want to cover.

    In many cases this value can be a nightmare to compute when the number of columns is dynamic, so we could need a colspan="all" or something like that. In practice, when you give a colspan value greater than the number of columns, you get the appropriate behaviour.

    So my question, in fine, is the following: is colspan="100" an appropriate, non-regressive, smart way to simulate a missing colspan="all"?

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,795
    Thanks
    19
    Thanked 156 Times in 147 Posts
    Sounds like reasonable logic....How hard would it be to test your theory?

    Also, if you are dynamically generating your tables, i don;t believe it would be that difficult to assign the number of columns to a variable and and then place it inside the colspan attribute....in PHP, you could do something like this:

    PHP Code:
    echo '<tr>
       <td colspan="' 
    $num_columns '"> content </td>
       </tr>'

    where $num_columns is whatever the result of your equation is that calculates the number of table columns....

    hope this helps...
    Last edited by chump2877; 03-11-2005 at 10:39 PM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #3
    New Coder
    Join Date
    Mar 2005
    Location
    France, Bordeaux
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It works properly with colspan="100" plus it's still XHTML compliant.

    When I say it's a nightmare, i mean unnecessary burden.

    It's clear it can be computed server-side, it's just that I'm a lazy man, and the less code (to maintain) for a given result the better...

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    The Netherlands, Baarn, Ut.
    Posts
    4,252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Bad practice

    However, it is still bad practice to specify a colspan value that has no relation to the actual number of columns to span; the fact that it works (now, in the browser you used to "test" it) doesn't mean that it's correct, and that it will remain to work (in a more strict browser, or a newer version).

    Moreover, this sort of colspan trickery is common where tables are abused for layout purposes; if this indeed is the case, you are strongly recommended to find another solution altogether, eleminating the very need for this sort of thing.
    Regards,
    Ronald.
    ronaldvanderwijden.com

  • #5
    New Coder
    Join Date
    Mar 2005
    Location
    France, Bordeaux
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I totally agree, it was more a general wondering than an actual need.

    In fact, there's no abuse of tables for layout purpose, it's really to display tables of data, otherwise I'd rather use floating divs. The point is the script allows to dynamically choose which columns (data fields) have to be displayed. I can offcourse compute the number on columns server-side and apply the right span.

    Note that an 'all' value could have been in the XHTML specification. Anyway, thanks for your opinion.

  • #6
    New Coder
    Join Date
    Mar 2005
    Location
    France, Bordeaux
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb colspan all exists actually but doesn't work

    In fact, according to attribute W3C recommendations on colspan, colspan="0" spans on all remaining columns, in the same column group, all columns by default.

    This is typically what I was looking for but it doesn't work, in Firefox 1.0.x at least.

    Shall we use uggly code that work, or proper that don't?



    Cheers,
    Last edited by MyttO; 03-23-2005 at 06:21 PM.

  • #7
    Regular Coder
    Join Date
    Aug 2004
    Location
    The Netherlands
    Posts
    211
    Thanks
    0
    Thanked 1 Time in 1 Post
    colspan="0" only works when you use the COLGROUP element.


  •  

    Posting Permissions

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