@namespace

Expression Studio 4.0

Declares an XML namespace (and, optionally, its prefix) and associates it with a string that represents a namespace name.

Syntax

@namespace sPrefix " sURL ";

Possible values

sPrefix

String that specifies the prefix that modifies the element to which it is attached.

sURL

A string that specifies a namespace name (that is, a URL).

Remarks

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.

Example

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


@namespace "http://www.w3.org/1999/xhtml";

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 "http://prfx.contoso.com";

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

prfx|E

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 "http://prfx.contoso.com";
@namespace msft "http://msft.example.com";
 p {background-color:red;}
prfx|p {background-color:blue;}
msft|p {background-color:green;}

The following code example styles a Scalable Vector Graphics (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 "http://www.w3.org/2000/svg";
svg|circle {fill:red;}

Standards information

This pseudo-element is defined in CSS Selectors Level 3 Gg721793.xtlink_newWindow(en-us,Expression.40).png.

See also

Concepts

@ rules

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.

Community Additions

ADD
Show: