CSS3名称空间是否用于XML以外的其他内容? [英] Are CSS3 namespaces used for anything except XML?

查看:36
本文介绍了CSS3名称空间是否用于XML以外的其他内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个希望我们使用CSS3名称空间的客户端.但是,我发现的所有内容都表明它专门用于样式化XML而不是HTML.任何人都可以验证将其用于CSS/HTML或阐明您将如何做吗?使用此方法的负面影响是什么?

We have a client that would like us to use CSS3 namespaces. However, everything I'm finding indicates that it is specifically used for styling XML and not HTML. Can anyone validate using it for CSS/HTML or clarify how you would do this? What are the negatives of following this method?

@namespace toto "http://toto.example.org";

toto|Product {
    display:block;
}

toto|Code {
    color: black
}

http://www.w3.org/TR/css3-namespace/

http://onwebdev.blogspot.com/2010/04/css3-namespace-selectors.html

推荐答案

任何人都可以验证是否将其用于CSS/HTML或阐明您将如何做吗?

Can anyone validate using it for CSS/HTML or clarify how you would do this?

主要的浏览器都使用默认的命名空间 http://www.w3.org/1999/xhtml ,这是XHTML的命名空间,甚至对于HTML来说,也是这样.不过从技术上讲,由于HTML并不是XML,除非您认为可以将基于SVG和MathML的基于XML的语言始终嵌入HTML中,否则没有任何意义.

Major browsers use a default namespace of http://www.w3.org/1999/xhtml which is XHTML's namespace, even for HTML, and go about their business. Technically though, since HTML isn't XML, there isn't a point to this unless you consider that XML-based languages like SVG and MathML can be embedded within HTML anyway.

如果您的客户想要使用CSS命名空间,则他们可能需要为您提供一些用某种语言编写的东西,该语言具有与CSS兼容的某种命名空间机制.尝试将此知识应用于HTML本身是没有意义的,因为

If your client wants to make use of CSS namespaces, they'll probably need to provide you with something that's written in a language that has some sort of namespacing mechanism that is compatible with CSS. It is meaningless to try and apply this knowledge to HTML itself because

  • HTML并非一开始就专门设计为命名空间
  • 浏览器已为(X)HTML文档分配了默认名称空间,您仍然无法显式访问该文档

更多信息可以在此答案中找到.

More information can be found in this answer.

要回答您的问题标题,文档语言不必一定是XML基于:

To answer your question title, the document language does not necessarily have to be XML-based:

除了本规范引入的术语外,CSS命名空间还使用XML 1.0的命名空间中定义的术语.但是,此处定义的语法不仅限于表示XML元素和属性名称,还可以表示宿主语言定义的其他类型的名称空间.

Besides terms introduced by this specification, CSS Namespaces uses the terminology defined in Namespaces in XML 1.0. However, the syntax defined here is not restricted to representing XML element and attribute names and may represent other kinds of namespaces as defined by the host language.

CSS命名空间规范借鉴了 XML命名空间的术语,只是因为CSS通常用于HTML和XML文档(即使那样,更多的人使用XSL(T)代替XSL(T)).

The CSS Namespaces spec borrows terminology from XML Namespaces as a convenience simply because CSS is most commonly applied to HTML and XML documents (and even then, more people use XSL(T) with the latter instead).

这篇关于CSS3名称空间是否用于XML以外的其他内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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