The CSS syntax module describes, in general terms, the structure and syntax of cascading stylesheets, or CSS. It defines CSS as the language for describing the rendering of structured documents (such as HTML and XML), on the web and elsewhere.
This module doesn't define any properties, data types, functions, or at-rules. Rather, it elaborates on how all of these features should be defined and how user agents should parse CSS.
Note: The module explicitly states that @charset is not an actual at-rule, but rather an unrecognized legacy rule that should be omitted when a stylesheet is grammar-checked. The only valid @charset usage is at the very beginning of a stylesheet, where it is interpreted as a special byte sequence stripped before processing the content.
Explains the overall CSS syntax and how declarations, declaration blocks, rulesets, and statements form the style rules.
Explains the formal grammar for defining valid values for CSS properties and functions, along with semantic constraints. A guide for understanding CSS component value types, combinators, and multipliers.
Overview of how browsers handle invalid CSS.
Introductory guide to CSS, including an introduction to CSS syntax.
CSS selectors module:
CSS cascading and inheritance module:
@import at-ruleimportant flagCSS custom properties for cascading variables module:
--*)var() functionCSS conditional rules module:
cssText propertyinsertRule(rule) methodreplace(text) methodWHATWG specification:
| Specification |
|---|
| Unknown specification> |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_syntax