简体   繁体   English

如何修复 W3 验证错误:表格行宽 X 列,超过了第一行 (X) 建立的列数

[英]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.

相关问题 表格行的宽度为2列,超过了第一行(1)建立的列数 - A table row was 2 columns wide and exceeded the column count established by the first row (1) HTML 错误 表格行宽 2 列,小于第一行建立的列数 (3) - HTML Error A table row was 2 columns wide, which is less than the column count established by the first row (3) 表格行的宽度为2列,小于第一行建立的列数(3) - A table row was 2 columns wide, which is less than the column count established by the first row (3) 复杂的HTML表无法验证:表行“超过了第一行建立的列数” - Complex HTML table not validating: table row “exceeded the column count established by the first row” 表格行的宽度为1列,小于第一行建立的计数(4) - A table row was 1 columns wide, which is less than the count established by the 1st row(4) 表行超出列数。 - Table row exceeded the column count. CSS:如何解决由创世纪主题引起的W3验证错误 - CSS : How do fix W3 Validation Error caused by Genesis theme W3验证错误 - 表格背景图片 - 表示没有背景属性 - W3 Validation error - table background image - says no attribute for background 如何解决 w3 验证错误错误值? - How to solve w3 validation error bad value? W3 CSS:行内的中心卡 - W3 CSS : Center Cards within Row
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM