简体   繁体   English

帮助解决HTML验证错误:“表格”列的开头没有单元格

[英]Help with HTML validation error: Table column has no cells beginning in it

Please help me with this validation error. 请帮助我解决验证错误。 I can't understand what it means or what's not standards complaint with my HTML. 我无法理解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. 由元素td建立的表列2的开头没有单元格。

…="tooltip_table"><tr><td colspan="2">20 yd range</td></tr><tr><td colspan="2"
                                     ↑

When you say colspan="2" , the column is supposed to stretch across two columns. 当您说colspan="2" ,该列应该跨越两列。 My guess would be that there is no second column defined anywhere else in the able, thus making colspan="2" impossible (and unnecessary). 我的猜测是,在语言能力的其他任何地方都没有定义第二列,因此使colspan="2"不可能(和不必要)。

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 :) 也许该规范中引用的表计算算法与4.01不同,但在我所在的时区中为时已晚,尝试解决该问题的方法为时已晚:)

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. 由元素td建立的表列2的开头没有单元格。

By using colspan="2" , you imply the existence of a second column, which doesn't exist in that case. 通过使用colspan="2" ,您意味着存在第二个列,在这种情况下不存在。 Common sense tells me it is correct to nag about. 常识告诉我na是正确的。

Maybe somebody can shed some light on this... Or it is, indeed, a bug. 也许有人可以对此有所了解……或者确实是一个错误。

HTML 5.2 Draft: Section 4.9.12.1 Forming a table HTML 5.2草案:4.9.12.1节形成表格

http://w3c.github.io/html/tabular-data.html#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. 步骤22:如果表中存在仅包含没有锚定单元格的插槽的表中的行或列,则这是表模型错误。

I believe it is a bug, and still unfixed. 我相信这是一个错误,并且仍未修复。 Consider this example page and run it through the W3C validator. 考虑此示例页面 ,并通过W3C验证器运行它。 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. 它会为“由元素td建立的表列3的开头没有单元格”给出错误,但是每个表都有4个单元格/列,而在第二个单元格上调用的“ colspan”为2。

Looks like an issue with the HTML5 validator. 看起来好像是HTML5验证程序有问题。 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. 如果您使用HTML 4.01 Transitional进行验证,则不会出现该错误,并且html5中的表html并未发生太大变化。

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 http://validator.w3.org/check?uri=http://www.wowpanda.net/s9712&charset=(自动检测+)&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 报告它可能是一个好主意

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. 当我对页面进行编程以在不显示第一行时从上一个示例中删除colspan时,错误消失了。 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. 只有一个单元格的colspan = 2就像告诉某人访问我在没有任何路口的街道上右转,认为他们会继续前进。 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. 不应期望浏览器“认为”您的意思可能与编写代码的方式不同。

Just fixing the link for Alohci's answer. 只需修复Alohci答案的链接。

https://w3c.github.io/html/single-page.html#forming-a-table 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. 如果表中存在仅包含没有锚定单元格的插槽的行或列,则这是表模型错误。

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. 如果您的表有8列,那么第一行必须有8个元素,如果您只是在初始化,就不想看到它。 The css element is: tr.Init{border:none;} and the following first row of an 8 column table. css元素是:tr.Init {border:none;}和8列表的以下第一行。 The result is - you don't see the first row and your validation errors are fixed. 结果是-您看不到第一行,并且您的验证错误已修复。

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. 使用标记定义每列将删除该消息,并为colspan提供一些相关内容。

More info in the answer here: Why is colspan not applied as expected 答案中的更多信息在这里: 为什么不按预期应用colspan

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM