Things I Learned Reading Webkit’s UA Stylesheet

submited by
Style Pass
2021-07-19 15:30:01

The very first thing I encounter, before any novel selectors, properties, or values, is this thing I’ve never seen or used in my life: @namespace.

Honestly, I dug around and never got to a point I where I feel like I can confidently say what it is and why you would use it.

The best example I could find for how/where you might use @namespace is from an O’Reilly book called Using SVG with CSS3 and HTML5. There’s a chapter about XML Namespaces in CSS describing how @namespace can help “when you want to distinguish between SVG and HTML elements with the same tag names”. As an example:

Anyhow, if novel things in CSS interest you and you’ve never heard of @namespace, you might want to read more from people who actually know what they’re talking about. FWIW: these links, in addition to the O’Reilly one above, were the most helpful to me:

Honestly, I’m not sure how these play out. It almost looks like they are executed/evaluated at runtime to apply conditional styling based on system-level configuration. Here’s another example:

Leave a Comment