This page is In Progress

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.



Declares the default namespace and binds a namespace to a namespace prefix.


The default namespace is applied to names that do not have an explicit namespace component. The following rule declares a default namespace.

@namespace "";

If you declare an @namespace rule with a prefix, you can use the prefix in namespace-qualified names. For example, consider the following namespace declaration for a namespace prfx.

@namespace prfx "";

Based on the previous declaration, the following selector matches E elements in the namespace that the prfx prefix refers to.


The following code example creates two namespace prefixes. First, p elements in any namespace are colored red. Any p elements in the prfx namespace are then recolored blue, and p elements in the msft namespace are recolored green.

@namespace prfx "";
@namespace msft "";
 p {background-color:red;}
prfx|p {background-color:blue;}
msft|p {background-color:green;}

The following code example styles a SVG element. By using the namespace and declaration from this example, all circles that are created with SVG are given a red fill.

@namespace svg "";
svg|circle {fill:red;}



The @namespace rule was introduced in Windows Internet Explorer 9. The scope of an @namespace rule is the style sheet that it is declared in. You must declare an @namespace rule after any @charset or @import rules.


@namespace prfx? sUrl


Optional. A String value that specifies a namespace prefix.
A URL Stringvalue that specifies a namespace name.

Related specifications

CSS Namespaces Module
W3C Recommendation

See also

Related articles