← Back to at-rules

CSS At-rule

@namespace

Structure

Defines XML namespaces for use in CSS selectors, primarily for SVG and MathML.

Syntax

@namespace prefix url('namespace');

Example

@namespace svg url('http://www.w3.org/2000/svg');

Common use cases

  • Targeting SVG elements specifically
  • Scoping styles in XML documents
  • Avoiding conflicts between HTML and SVG elements

Practical developer insight

@namespace is rarely needed in day-to-day web development — it's mainly useful when working with inline SVG or XML-based documents.

Related