在colgroup和col上的跨度属性 [英] Span attribute on colgroup and col

查看:259
本文介绍了在colgroup和col上的跨度属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这些代码在逻辑上是否相同?

 < colgroup span =7> 
< / colgroup>



 < col span =7/> 



 < COLGROUP> 
< col />
< col />
< col />
< col />
< col />
< col />
< col />
< / colgroup>

通过HTML或属性通过CSS的任何属性是否具有相同的效果? sombody也可以添加colgroup标签。没有足够的代表让我做到这一点。 < col> 的规范:


可以使用此元素的上下文:

作为colgroup元素的子元素没有span属性。

[...]

内容属性:
全局属性

span


我读过< col span =7/> code>本身是无效的,但这是:

 < colgroup> 
< col span =7/>
< / colgroup>

有效且相同:

 < colgroup span =7> 
< / colgroup>

但是,如果 < colgroup> 有一个 span 属性,那么它不应该有< col> 子女:


如果colgroup元素不包含col元素,那么该元素可能会指定span内容属性...


我的解释(基于 HTML4规范更多而不是更薄的HTML5版本)是您通常会使用< colgroup span =n> ,除非您需要以不同的方式设置组中的某一列这个来自HTML4规范的(修改过的)例子:

 < colgroup style =width:20px; font-weight:bold; > 
< col span =39>
< col id =format-me-specialstyle =width:35px;>
< / colgroup>

所以前39列将使用任何< colgroup> 指定,但第40个可以调整。 OTOH,我无法让浏览器在jsfiddle.net上注意这些(尽管规格说明),所以YMMV。


Are these codes logically equivalent?

<colgroup span="7">
</colgroup>

And

<col span="7" />

And

<colgroup>
<col />
<col />
<col />
<col />
<col />
<col />
<col />
</colgroup>

Will any attributes via HTML or properties via CSS have equal effect? Can sombody also add "colgroup" Tag. No enough rep for me to do that.

解决方案

From the specification for <col>:

Contexts in which this element can be used:
As a child of a colgroup element that doesn't have a span attribute.
[...]
Content attributes: Global attributes
span

I read that as saying that just <col span="7" /> on its own is invalid but this:

<colgroup>
    <col span="7" />
</colgroup>

is valid and the same as:

<colgroup span="7">
</colgroup>

However, if the <colgroup> has a span attribute, then it should not have <col> children:

If the colgroup element contains no col elements, then the element may have a span content attribute specified...

My interpretation (based on the HTML4 specification more than the thinner HTML5 one) is that you would usually use <colgroup span="n"> unless you needed to style one of the columns in the group differently as in this (modified) example from the HTML4 specification:

<colgroup style="width: 20px; font-weight: bold;">
    <col span="39">
    <col id="format-me-specially" style="width: 35px;">
</colgroup>

so the first 39 columns would use whatever the <colgroup> specifies but the 40th could be tweaked. OTOH, I'm having trouble getting browsers to pay much attention to any of this (despite what the specs say) on jsfiddle.net so YMMV.

这篇关于在colgroup和col上的跨度属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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