An at-rule is a CSS statement beginning with an at sign, '
U+0040 COMMERCIAL AT), followed by an identifier and includes everything up to the next semi-colon, '
U+003B SEMICOLON), or the next CSS block, whichever comes first.
There are several at-rules, designated by their identifiers, each with a different syntax:
@charset— Defines the character set used by the style sheet.
@import— Tells the CSS engine to include an external style sheet.
@namespace— Tells the CSS engine that all its content must be considered prefixed with an XML namespace.
- Nested at-rules — A subset of nested statements, which can be used as a statement of a style sheet as well as inside of conditional group rules:
@media— A conditional group rule which will apply its content if the device meets the criteria of the condition defined using a media query.
@supports— A conditional group rule which will apply its content if the browser meets the criteria of the given condition.
@document— A conditional group rule which will apply its content if the document in which the style sheet is applied meets the criteria of the given condition. (deferred to Level 4 of CSS Spec)
@page— Describes the aspect of layout changes which will be applied when printing the document.
@font-face— Describes the aspect of an external font to be downloaded.
@keyframes— Describes the aspect of intermediate steps in a CSS animation sequence.
@viewport— Describes the aspects of the viewport for small screen devices. (currently at the Working Draft stage)
@counter-style— Defines specific counter styles that are not part of the predefined set of styles. (at the Candidate Recommendation stage, but only implemented in Gekko as of writing)
— Define common names in
font-variant-alternatesfor feature activated differently in OpenType. (at the Candidate Recommendation stage, but only implemented in Gekko as of writing)
Conditional Group Rules
Much like the values of properties, each at-rule has a different syntax. Nevertheless, several of them can be grouped into a special category named conditional group rules. These statements share a common syntax and each of them can include nested statements—either rulesets or nested at-rules. Furthermore, they all convey a common semantic meaning—they all link some type of condition, which at any time evaluates to either true or false. If the condition evaluates to true, then all of the statements within the group will be applied.
Conditional group rules are defined in CSS Conditionals Level 3 and are:
Since each conditional group may also contain nested statements, there may be an unspecified amount of nesting.
|CSS Conditional Rules Module Level 3||Candidate Recommendation||Initial definition|
|Web Compatibility Standard
The definition of 'CSS At-rules' in that specification.
- CSS Reference
- CSS Key Concepts: CSS syntax, at-rule, comments, specificity and inheritance, the box, layout modes and visual formatting models, and margin collapsing, or the initial, computed, resolved, specified, used, and actual values. Definitions of value syntax, shorthand properties and replaced elements.