请解释 rowspan 和 colspan、col 和 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
colspan
rowspan
w3c
如您所见,这是用于连接表格单元格 - 因为有时这是必要的,所以它是有效的(RegDwights 链接将提供更多信息...)。
col/colgroup
colgroup
和col
用于为表格中的每一行设置属性(因此您不必编写width="80"td
(tr
))):您还可以对列进行分组,假设第一列和第二列应该得到一个
with< /code> 为 80,第三个应该得到 320:
colspan
rowspan
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...).
col/colgroup
colgroup
andcol
are used to set attributes to every line in the table (so you don't have to writewidth="80"
for the firsttd
in every line(tr
)):you can also group the cols, lets say the first and second column should get a
with
of 80, the third should get 320:是的,它们都是W3C推荐的。以下是文档的直接链接:
col
colgroup
colspan
rowspan
Yes, they are all recommended by W3C. Here are direct links to the documentation:
col
colgroup
colspan
rowspan
rowspan 和 colspan 是允许设计者“合并”单元格的属性 - 非常类似于 Excel 中的相同命令(例如)。
col
和colgroup
允许设计者将 css 应用到垂直列,而不必将 css 应用到列中的各个单元格。如果没有这些,这个任务将会困难得多,因为 html 表是基于行的。这四个都是有效的。
为了便于将来参考,请尝试 http://reference.sitepoint.com/html
rowspan
andcolspan
are attributes that allow the designer to 'merge' cells - much like the same command in Excel (for example).col
andcolgroup
allow the designer to apply css to a vertical column, rather than having to apply css to individual cells in a column. Without these, this task would be much more difficult as html tables are row-based.All four of these are valid.
For future reference, try http://reference.sitepoint.com/html