[英]How to fix W3 Validation error: A table row was X columns wide and exceeded the column count established by the first row (X)
I ran this table in the W3 validator and it fails.我在 W3 验证器中运行了这个表,但它失败了。 I get this message "Error A table row was 6 columns wide and exceeded the column count established by the first row (2)".
我收到此消息“错误表行为 6 列宽,超出了第一行 (2) 建立的列数”。
table td:not(:first-of-type) { display: block; } table{ border-collapse: collapse; } table *{ vertical-align: top; } thead{ border-bottom: 1px solid #a1afba; } th,td { padding: 3px 15px 3px 0; } td:last-of-type{ padding-bottom: 20px; }
<table> <thead> <tr> <th scope="col">Dates</th> <th scope="col">Price per week</th> </tr> </thead> <tr> <td>00/00/00 - 00/00/00</td> <td>lorem $000</td> <td>lorem $000</td> <td>lorem $000</td> <td>lorem $000</td> </tr> <tr> <td>00/00/00 - 00/00/00</td> <td>lorem $000</td> <td>lorem $000</td> </tr> </table>
I tried adding colspan="1"
to the the "dates" th, and colspan="100"
to the "price per week" th, since the number of tds for the prices can be any, but I still get the warning in W3.我尝试将
colspan="1"
添加到 "dates" th,并将colspan="100"
添加到 "price per week" th,因为价格的 tds 数量可以是任意的,但我仍然收到警告W3。
How can i get rid of the error?我怎样才能摆脱错误?
Thanks in advance!提前致谢!
Each row (tr) has to have the same amount of cells (td).每行 (tr) 必须具有相同数量的单元格 (td)。 Except if you are using colspan, but then the sum of the spanned cells and the other (single) cells still have to be the same amount.
除非您使用 colspan,但跨单元格和其他(单个)单元格的总和仍然必须相同。
So your table have to look like this:所以你的桌子必须看起来像这样:
<table> <thead> <tr> <th scope="col">dates</th> <th scope="col">price per week</th> </tr> </thead> <tr> <td>00/00/00 - 00/00/00</td> <td>lorem $000</td> </tr> <tr> <td></td> <td>lorem $000</td> </tr> <tr> <td></td> <td>lorem $000</td> </tr> <tr> <td></td> <td>lorem $000</td> </tr> <tr> <td>00/00/00 - 00/00/00</td> <td>lorem $000</td> </tr> <tr> <td></td> <td>lorem $000</td> </tr> </table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.