Skip to content Skip to sidebar Skip to footer

Are Css3 Namespaces Used For Anything Except Xml?

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

Solution 1:

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

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.

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 wasn't exactly designed to be namespaced in the first place
  • browsers already assign a default namespace to (X)HTML documents that you can't access explicitly anyway

More information can be found in this answer.

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

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.

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).

Solution 2:

CSS namespaces are not about logically grouping CSS rules (a la namespaces in C++ and C#), but about applying rules as they apply to namespaced elements in a given host-language (in this case, XML documents with XML namespaces), but the specification is language-neutral so it could work with JSON (if someone invents namespaces for that) or any other structured language ( http://www.w3.org/TR/css3-namespace/ ).

2.1. Terminology

[..] 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.

Solution 3:

Post a Comment for "Are Css3 Namespaces Used For Anything Except Xml?"