[英]HTML validation error-Table columns in range 4…5 established by element th have no cells beginning in them
EDIT: I used the W3 validator. 编辑:我使用了W3验证器。 I have a problem when I try to validate my html code.
我尝试验证html代码时遇到问题。 I've tried to google the answer, but I can't seem to find a way to fix it.
我试图用谷歌搜索答案,但似乎找不到解决方法。 If someone could please explain to me what is causing the error and how to fix it, i would be very happy.
如果有人可以向我解释是什么导致了错误以及如何解决该错误,我将非常高兴。 Error message: Line 80, Column 19: Table columns in range 4…5 established by element th have no cells beginning in them.
错误消息:第80行,第19列:由元素th建立的范围为4…5的表列中没有任何单元格。 th colspan="6"Köpt utrustning/th.
th colspan =“ 6”Köptutrustning / th。
Here is the code related to that table: 这是与该表相关的代码:
<div id="tabell2Space">
<div id="tabell2">
<table>
<tr>
<th colspan="6">Köpt utrustning</th>
</tr>
<tr>
<th rowspan="2">Artikelnummer#</th>
<th rowspan="2">Artikelbild</th>
<th colspan="3">Beskrivning</th>
<th>Pris</th>
</tr>
<tr>
<th colspan="3">Frakt, installation, etc</th>
<th>Kostnad</th>
</tr>
<tr>
<td rowspan="2">1.</td>
<td rowspan="2"><img alt="Dator" src="Bilder/pryl2.jpg"></td>
<td colspan="3">IMB Clone computer</td>
<td>$ 400.00</td>
</tr>
<tr>
<td colspan="3">Frakt, installation, etc</td>
<td>$ 20.00</td>
</tr>
<tr>
<td rowspan="2">2.</td>
<td rowspan="2"><img alt="Datorkomponent" src="Bilder/pryl1.jpg"></td>
<td colspan="3">1GB RAM Module</td>
<td>$ 50.00</td>
</tr>
<tr>
<td colspan="3">Frakt, installation, etc</td>
<td>$ 14.00</td>
</tr>
<tr>
<th colspan="6">Köpt utrustning</th>
</tr>
</table>
</div>
</div>
Any help is appreciated! 任何帮助表示赞赏!
The table structure violates the HTML table model, which has now been formalized in HTML5, and the W3C HTML5 validator checks against it. 该表结构违反了HTML表模型,该模型现已在HTML5中进行了形式化,并且W3C HTML5验证程序对其进行检查。 The model is described in section 4.9.12 Processing model of chapter 4.9 Tabular data of the HTML5 spec.
该模型在HTML5规范的4.9章表格数据的4.9.12 处理模型部分中进行了描述。 It's rather technical, but the point is that a table consists of rows and columns, which define a grid of slots, and each slot must have a cell starting in it.
这是相当技术性的,但要点是表由行和列组成,这些行和列定义了一个插槽网格,并且每个插槽必须在其中开始有一个单元格。
In your case, the real problem is that you declare six columns, but slots in columns 4 and 5 have no cells starting in them. 在您的情况下,真正的问题是您声明了六列,但是列4和5中的插槽中没有开始的单元格。 To put it in another, probably more useful way, your table really has just four columns (as you can see if you add borders around cells, as @PHJCJO suggested), but you have declared otherwise, as if the third real column consisted of three columns.
换句话说,您的表实际上只有四列(如您所看到的那样,是否在单元格周围添加边框,如@PHJCJO所建议的那样),但是您已声明否则,好像第三实数列由三列。
The fix is this to remove all those colspan="3"
attributes that do this and accordingly change colspan="6"
to colspan="4"
. 解决方法是删除所有执行此操作的
colspan="3"
属性,并相应地将colspan="6"
更改为colspan="4"
。 The following code implements this, and validates, and creates the same rendering except possibly for the width of the third column, which should be set in CSS if needed. 以下代码实现了这一点,并进行了验证,并创建了相同的渲染,除了第三列的宽度(可能需要在CSS中设置)外。 Borders are included here just for clarity.
为了清楚起见,此处包括边框。
<div id="tabell2Space"> <div id="tabell2"> <table border> <tr> <th colspan="4">Köpt utrustning</th> </tr> <tr> <th rowspan="2">Artikelnummer#</th> <th rowspan="2">Artikelbild</th> <th>Beskrivning</th> <th>Pris</th> </tr> <tr> <th>Frakt, installation, etc</th> <th>Kostnad</th> </tr> <tr> <td rowspan="2">1.</td> <td rowspan="2"><img alt="Dator" src="Bilder/pryl2.jpg"></td> <td>IMB Clone computer</td> <td>$ 400.00</td> </tr> <tr> <td>Frakt, installation, etc</td> <td>$ 20.00</td> </tr> <tr> <td rowspan="2">2.</td> <td rowspan="2"><img alt="Datorkomponent" src="Bilder/pryl1.jpg"></td> <td>1GB RAM Module</td> <td>$ 50.00</td> </tr> <tr> <td>Frakt, installation, etc</td> <td>$ 14.00</td> </tr> <tr> <th colspan="4">Köpt utrustning</th> </tr> </table> </div> </div>
Semantically, using <th>
(indicating a row/column header) should be followed by one or more <th>
s, unless the <th>
is in the <thead>
. 在语义上,除非
<th>
在<thead>
,否则使用<th>
(表示行/列标题)后应跟一个或多个<th>
<thead>
。 I would use a <td colspan="6">Köpt utrustning</td>
instead of <th>
, and just style it to be bold if that's the effect you're going for. 我将使用
<td colspan="6">Köpt utrustning</td>
代替<th>
,如果您<td colspan="6">Köpt utrustning</td>
,只需将其设置为粗体即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.