Re: HTML5 Validator doesn't appear to understand colspan

2011-12-29 17:51, Pat MacMannis wrote:

> This is in reply to the "Re: HTML5 Validator doesn't appear to
> understand colspan" thread

The initial message, archived at
http://lists.w3.org/Archives/Public/www-validator/2011May/0018.html
suggested that the problem was: “The HTML5 validator doesn't seem to 
understand a colspan attribute [...] in the first row of a table.” But 
the explanations given by Michael Smith, of the W3C, pointed out that 
the problem is in the table structure as a whole.

Basically, the HTML5 table model contains the principle that colspan 
must not be used in vain. It is OK to make a cell extend to several 
columns or, to use the HTML5 terms, to occupy several “slots,” but it is 
not OK to create a column that exists *only* via colspan attributes, 
without having real cells of its own. The rationale is that such 
constructs make table structures unnecessarily complicated.

The logic isn’t easy to follow, but it makes sense after some 
consideration. It is, however, difficult to formulate error messages 
about violating the principle.

> The error message, "Table columns in range 3...4 established by
> element td have no cells beginning in them" does little to clearly
> help determine what exactly is failing.

It’s undoubtedly difficult to see what the error message is really 
saying, but what can you do? The only thing that came into my mind is 
adding a link to the specification, with appended text like
“which violates the <a href=...>HTML5 table model</a>”
but the text in the spec is rather formal and complicated. Ideally, the 
error message should link to a short page that explains the HTML5 table 
model in simple prose and links to the spec for the formalese.

> The error seems to have been
> thrown because the validator does not allow for the colspan attribute
> to be used in the first row (unless colspan='1' is used).

No, that’s not the cause. The following document validates OK:

<!doctype html>
<title></title>
<table>
<tr><td colspan=2>
<tr><td>hello <td>world
</table>

But if the “2” is replaced by “3,” an error message is issued, because 
then there are no cells in the 3rd column, but <td colspan=3> would 
require 3 columns.

It is quite normal and OK to have colspan in the first row. In a table 
for tabular data, it typically means that some column header acts as a 
header for several columns. But that would not be OK if it required more 
columns than the table has in its structure.

Yucca

Received on Friday, 30 December 2011 11:48:36 UTC