请解释rowspan和colspan,col和colgroup [英] Please explain rowspan and colspan, col and colgroup
问题描述
任何人都可以解释 rowspan
和 colspan
, col
和 colgroup
?这些W3C是否有效和语义正确?在哪些情况下这些有用?
Can anyone explain rowspan
and colspan
, col
and colgroup
? And are these W3C valid and semantically correct? Under which circumstances are these useful?
推荐答案
colspan
colspan
<table border="1">
<tr>
<th colspan="2">people are...</th>
</tr>
<tr>
<td>monkeys</td>
<td>donkeys</td>
</tr>
</table>
rowspan
rowspan
<table border="1">
<tr>
<th rowspan="2">monkeys are...</th>
<td>... real monkeys</td>
</tr>
<tr>
<td>... 'unreal' monkeys (people...)</td>
</tr>
</table>
w3c
是用于连接表格单元格 - 并且因为这有时是必要的,它是有效的(RegDwights链接将给更多的信息...)。
w3c
as you see, this is for connecting table-cells - and because this is sometimes neccessary, it's valid (RegDwights links will give more information...).
colgroup
和 col
用于将属性设置为(因此您不必为每行中的第一个 td
写 width =80
code> tr )):
colgroup
and col
are used to set attributes to every line in the table (so you don't have to write width="80"
for the first td
in every line(tr
)):
<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>
您也可以对cols进行分组,让第一列和第二列得到 with
of 80,the third should get 320:
you can also group the cols, lets say the first and second column should get a with
of 80, the third should get 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>
这篇关于请解释rowspan和colspan,col和colgroup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!