...

View Full Version : replacement for colspan?



bazz
01-22-2008, 09:05 PM
HI,

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



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


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

oesxyl
01-22-2008, 09:56 PM
<!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

bazz
01-22-2008, 11:25 PM
Thank you oesxyl.

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

bazz

VIPStephan
01-23-2008, 12:18 AM
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:


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

bazz
01-23-2008, 04:31 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum