HTML类属性带空格,它是一个W3C有效类吗? [英] HTML class attribute with spaces, it is a W3C valid class?

查看:280
本文介绍了HTML类属性带空格,它是一个W3C有效类吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于HTML class 属性,将CSS类(或类?)分配给标记。
使用空格,如

 < tag class =ab> .... ; / tag> 

有效?



由一些网页设计师使用,并发生在Adobe InDesign的导出的HTML(测试版本5和6)和另一个HTML生成软件...



class =ab)是有效的W3C语法吗?什么版本的CSS和HTML?
(从哪个版本开始生效?)






EDIT:自然的子问题W3C说怎么解释呢? (它是覆盖还是其他呈现行为?)发布于此

解决方案

这些是两个不同的类 a b 以空格分隔。请参阅 w3c DOCS



class = cdata-list [CS]




此属性为
元素分配一个类名或一组类名。任何数量的元素可以被分配相同的类名或
名。多个类名必须用空格分隔
个字符。







你有两个类

  .a {font-weight:bold; } 
.b {font-weight:normal; } =ba,则以后的类将覆盖具有相同属性的先前类,因此字体重量将正常



如果您更改CSS定义顺序,

  .b { font-weight:normal; } 
.a {font-weight:bold; }

现在后面的类是粗体,因此覆盖具有相同属性的先前类结果 font weight bold


About HTML class attribute, that assigns CSS class (or classes?) to a tag. The use of spaces, like in

<tag class="a b">....</tag>

is valid?

This syntax is used by some web-designers and occurs into exported HTML of Adobe InDesign (tested with versions 5 and 6), and another HTML generation softwares...

It (class="a b") is a valid W3C syntax? What versions of CSS and HTML? (starting from which version became valid?)


EDIT: a natural subquestion "W3C say how to interpret it?" (it is an "override" or another renderization behaviour?) was posted here.

解决方案

these are two different classes a & b separated by space. see w3c DOCS

class = cdata-list [CS]

this attribute assigns a class name or set of class names to an element. Any number of elements may be assigned the same class name or names. Multiple class names must be separated by white space characters.


If you have two class

.a { font-weight: bold; }
.b { font-weight: normal; }

and assign in class="a b" or class="b a", then later class will overwrite the prior class having same property, so font weight will be normal.

If you change the CSS definition order,

.b { font-weight: normal; }
.a { font-weight: bold; }

now the later class is bold, so "overwrite the prior class having same property" results font weight bold.

这篇关于HTML类属性带空格,它是一个W3C有效类吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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