24

Please help me with this validation error. I can't understand what it means or what's not standards complaint with my HTML.

I'll repost it here since hopefully I'll fix it and that link will no longer work:

Table column 2 established by element td has no cells beginning in it.

…="tooltip_table"><tr><td colspan="2">20 yd range</td></tr><tr><td colspan="2"
                                     ↑
Andreas Bonini
  • 44,018
  • 30
  • 122
  • 156

8 Answers8

19

When you say colspan="2", the column is supposed to stretch across two columns. My guess would be that there is no second column defined anywhere else in the able, thus making colspan="2" impossible (and unnecessary).

I can't find anything in the spec explicitly saying it's illegal. Maybe the table calculating algorithm quoted in that spec is different from 4.01, but it's way too late in my time zone to try and get around that :)

However, I find the error message makes too perfect sense to be an outright bug.

Table column 2 established by element td has no cells beginning in it.

By using colspan="2", you imply the existence of a second column, which doesn't exist in that case. Common sense tells me it is correct to nag about.

Maybe somebody can shed some light on this... Or it is, indeed, a bug.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
12

HTML 5.2 Draft: Section 4.9.12.1 Forming a table

http://w3c.github.io/html/tabular-data.html#forming-a-table

Step 22: If there exists a row or column in the table containing only slots that do not have a cell anchored to them, then this is a table model error.

Alohci
  • 78,296
  • 16
  • 112
  • 156
3

I believe it is a bug, and still unfixed. Consider this example page and run it through the W3C validator. It gives errors for "Table column 3 established by element td has no cells beginning in it.", and yet each table has 4 cells/columns, and the "colspan" of 2 is called on the second cell.

Will
  • 31
  • 3
  • Also, for the record, that next table cell--I tried it with "display: hidden", which is the default, and I tried it without; in each case, the error comes up, so the CSS display (hidden or visible) of the cell is NOT what is causing this bug. I quadruple-checked this. – Will Apr 21 '11 at 22:51
  • 1
    Also, I've added this bug to the Validator.nu Bugzilla list: [link](http://bugzilla.validator.nu/show_bug.cgi?id=826) – Will Apr 22 '11 at 16:02
  • I think we've got it figured out. Needed another row with full cell count before using colspan. HTML5 picks up on the error, whereas previous doctypes let it slide. – Will Apr 24 '11 at 03:24
1

Looks like an issue with the HTML5 validator. That error does not come up if you validate is with HTML 4.01 Transitional, and the table html has not been changed that much in html5.

http://validator.w3.org/check?uri=http://www.wowpanda.net/s9712&charset=(detect+automatically)&doctype=HTML+4.01+Transitional&ss=1&outline=1&group=0&verbose=1&user-agent=W3C_Validator/1.654

Reporting it is probably a good idea

glebm
  • 20,282
  • 8
  • 51
  • 67
  • HTML 5 and 4.01 are entirely different beasts, and the fact that the one applies a different rule set than the other is, even though it might, not necessarily a "bug." Without more evidence, I think there is no need for the b-word :) – Pekka Feb 18 '10 at 23:25
  • Point taken. However, before posting the answer I read this: http://www.w3.org/TR/html5/tabular-data.html And there is no evidence whatsoever that the
    structure changed that much. Let's call it an Issue, because we are not sure it is a bug :)
    – glebm Feb 18 '10 at 23:26
  • @Glex I just came back from reading the same document :) There's indeed nothing in there but to me, the error message makes too much sense to be a bug. Well, we'll see, if a report gets filed I would be interested to know what comes out of it. – Pekka Feb 18 '10 at 23:34
  • Henri Sivonen's validator says the same, so it would be a bug in two independent validators? (They *are* independent, aren't they?) http://html5.validator.nu/?doc=http%3A%2F%2Fwww.wowpanda.net%2Fs9712 – Marcel Korpel Feb 18 '10 at 23:41
  • @Marcel - I think they are one and the same. – Alohci Feb 19 '10 at 01:42
  • The legacy validator simply doesn't check for this class of error at all. This is an improvement over legacy--not a bug in the HTML5 validator. – hsivonen May 11 '10 at 11:04
1

I had the same error on a dynamically created table. Depending on the input, some rows were displayed or not. Like this:

Causes no error:

<table>
<tr>
<td> cell 1 in row 1 </td>
<td> cell 2 in row 1 </td>
</tr>
<tr>
<td colspan=2> one cell in row 2 </td>
</tr>
</table>

Causes no error:

<table>
<tr>
<td> cell 1 in row 1 </td>
<td> cell 2 in row 1 </td>
</tr>
</table>

Causes an error:

<table>
<tr>
<td colspan=2> one cell in what is now the only row </td>
</tr>
</table>

Once I programmed the page to delete the colspan from the last example when the first row was not displayed, the error disappeared. Something like this:

<?php if (first row with two cells is displayed) echo 'colspan=2'; ?>

I find this logical. colspan=2 with only single cells is like telling someone visiting me to turn right on a street that does not have any junctions, believing that they will continue straight on. They won't. Instead they will get hung up searching for something that is not there. Maybe not a completely accurate analogy, but you can imagine a dumb browser creating display errors while looking for stuff that you tell it is there, but is not. Browsers shouldn't be expected to "think" that maybe you meant your code differently from how you wrote it.

1

Just fixing the link for Alohci's answer.

https://w3c.github.io/html/single-page.html#forming-a-table

  1. If there exists a row or column in the table containing only slots that do not have a cell anchored to them, then this is a table model error.
riddler
  • 83
  • 1
  • 7
0

If you initiate the table - it fixes the validation column errors. If your table has 8 columns then the first row must have 8 elements, which if you are only initiating you don't want to see. The css element is: tr.Init{border:none;} and the following first row of an 8 column table. The result is - you don't see the first row and your validation errors are fixed.

0

This thread is a bit old but I post this for anyone bumping into it.

Defining each column using tag removes the message and also gives the colspan something to relate to.

More info in the answer here: Why is colspan not applied as expected

Community
  • 1
  • 1
Nicsoft
  • 3,644
  • 9
  • 41
  • 70