HTML表colgroup元素不工作? [英] HTML table colgroup element not working?

查看:223
本文介绍了HTML表colgroup元素不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在表格的每一列上使用不同的样式。我已经读过,你可以使用< colgroup> < col> 没有运气。我有一个示例这里,没有任何改变。我做错了什么?这将在xhtml上工作吗?



我知道我可以在每个< td> 上添加一个class属性,但似乎很弱。

解决方案

这是正确的。虽然所有浏览器都支持 colgroup 本身,但这些属性并非如此元素的 col 元素。在可能的属性中,所有浏览器只支持 width 。但不像CSS,< col width => 只支持像素和百分比宽度。



< t使用它。相反,创建CSS类并将它们分配给每个 td



编辑已将上面的链接更新到包含更好信息的页面


I want different styles on each column of a table. I've read that you could do that by using <colgroup> or <col>, but I had no luck. I have an example here, and nothing seems to change. Am I doing something wrong? Will this work on xhtml?

I know I could add a "class" attribute on each <td>, but that seems weak.

解决方案

That's correct. While colgroup itself is supported by all browsers, this isn't true for the attributes of the inner col element. Of possible attributes, only width is supported on all browsers. But unlike CSS, <col width=""> only supported pixel and percentage widths.

Don't use it. Instead, create CSS classes and assign them to each td. Yes, it sucks.

EDIT Updated link above to page with better information

这篇关于HTML表colgroup元素不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆