HTML 表格 colgroup 元素不起作用? [英] HTML table colgroup element not working?

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

问题描述

我希望表格的每一列都有不同的样式.我已经读到你可以通过使用 来做到这一点,但我没有运气.我有一个例子 here,似乎没有任何改变.难道我做错了什么?这会在 xhtml 上工作吗?

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?

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

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

推荐答案

没错.虽然 colgroup 本身支持所有浏览器这不适用于内部 col 元素 的属性.在可能的属性中,所有浏览器仅支持 width.但与 CSS 不同的是,<col width=""> 仅支持像素和百分比宽度.

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 supports pixel and percentage widths.

不要使用它.相反,创建 CSS 类并将它们分配给每个 td.是的,这很糟糕.

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天全站免登陆