...

View Full Version : colspan="all" could be colspan="100"?



MyttO
03-11-2005, 10:21 AM
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"?

chump2877
03-11-2005, 11:33 AM
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:


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...

MyttO
03-11-2005, 11:52 AM
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...

ronaldb66
03-11-2005, 01:17 PM
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.

MyttO
03-11-2005, 05:28 PM
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.

MyttO
03-23-2005, 07:18 PM
In fact, according to attribute W3C recommendations on colspan (http://www.w3.org/TR/REC-html40/struct/tables.html#adef-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?

:confused: :confused: :confused:

Cheers,

Jero
03-23-2005, 08:36 PM
colspan="0" only works when you use the COLGROUP element.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum