Css 请解释rowspan和colspan、col和colgroup

Css 请解释rowspan和colspan、col和colgroup,css,xhtml,semantic-markup,Css,Xhtml,Semantic Markup,谁能解释一下rowspan和colspan,col和colgroup?这些W3C是否有效,语义是否正确?在什么情况下这些有用?是的,它们都是W3C推荐的。以下是文档的直接链接: rowspan和colspan是允许设计器“合并”单元格的属性,非常类似于Excel中的同一命令(例如) col和colgroup允许设计器将css应用于垂直列,而不必将css应用于列中的单个单元格。如果没有这些,这项任务将更加困难,因为html表是基于行的 这四项都是有效的 为便于将来参考,请尝试colspa

谁能解释一下
rowspan
colspan
col
colgroup
?这些W3C是否有效,语义是否正确?在什么情况下这些有用?

是的,它们都是W3C推荐的。以下是文档的直接链接:


rowspan
colspan
是允许设计器“合并”单元格的属性,非常类似于Excel中的同一命令(例如)

col
colgroup
允许设计器将css应用于垂直列,而不必将css应用于列中的单个单元格。如果没有这些,这项任务将更加困难,因为html表是基于行的

这四项都是有效的

为便于将来参考,请尝试

colspan 您还可以对col进行分组,假设第一列和第二列的
值为80,第三列的
值为320:

<table border="1">
  <colgroup width="80" span="2"></colgroup>
  <colgroup width="320" span="1"></colgroup>
  <tr>
    <td>first line, first column</td>
    <td>first line, second column</td>
    <td>first line, third column</td>
  </tr>
  <!-- more table-lines... -->
</table>

第一行,第一列
第一行,第二列
第一行,第三列

添加了col/colgroup,希望这有帮助。我们可以使用width=“80”吗?如果我没记错的话,宽度只在td、th、pre和。。。其他一些东西-但是如果你不想使用它,你可以通过使用样式表获得同样的效果。
<table border="1">
  <tr>
    <th rowspan="2">monkeys are...</th>
    <td>... real monkeys</td>
  </tr>
  <tr>
    <td>... 'unreal' monkeys (people...)</td>
  </tr>
</table>
<table border="1">
  <colgroup>
    <col width="80">
    <col width="100">
    <col width="320">
  </colgroup>
  <tr>
    <td>first line, first column</td>
    <td>first line, second column</td>
    <td>first line, third column</td>
  </tr>
  <!-- more table-lines... -->
</table>
<table border="1">
  <colgroup width="80" span="2"></colgroup>
  <colgroup width="320" span="1"></colgroup>
  <tr>
    <td>first line, first column</td>
    <td>first line, second column</td>
    <td>first line, third column</td>
  </tr>
  <!-- more table-lines... -->
</table>