CSS syntax
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.
At-rules
- none
[!NOTE] The module explicitly states that {{cssxref("@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.
Reference
Key concepts
- {{cssxref("at-rule")}}
- character escaping
- CSS comments
- CSS declaration
- CSS declaration block
- CSS function
- invalid
- style rule
Glossary terms
- {{glossary("CSS_Descriptor", "CSS descriptor")}}
- {{glossary("parse")}}
- {{glossary("stylesheet")}}
- {{glossary("whitespace")}}
Guides
-
- : Overview of CSS syntax, including CSS declarations, declaration blocks, rulesets, and statements.
-
- : 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 the user agent handles invalid CSS.
-
Learn CSS first steps: CSS syntax
- : Introductory guide to CSS, including an introduction to CSS syntax.
Related concepts
CSS selectors module:
CSS cascade module:
- {{cssxref("@import")}} at-rule
- {{cssxref("important")}} flag
- Initial values
- Computed values
- Used values
- Actual values
- CSS inheritance
- {{Glossary("Property/CSS", "CSS property")}}
CSS custom properties for cascading variables module:
- custom property (
--*
) - {{cssxref("var")}} function
CSS conditional rules module:
- {{cssxref("@media")}} at-rule
- {{cssxref("@supports")}} at-rule
- {{domxref("CSSValue.cssText", "cssText")}} property
- {{domxref("CSSStyleSheet.insertRule()", "insertRule(rule)")}} method
- {{domxref("CSSStyleSheet.replace()", "replace(text)")}} method
WHATWG specification:
Specifications
See also
- CSS selectors module
- CSS values and units module