At-rules

At-rules are CSS statements that instruct CSS how to behave. They begin with an at sign, '@' (U+0040 COMMERCIAL AT), followed by an identifier and includes everything up to the next semicolon, ';' (U+003B SEMICOLON), or the next CSS block, whichever comes first.

Syntax

Regular

/* General structure */
@IDENTIFIER (RULE);

/* Example: tells browser to use UTF-8 character set */
@charset "utf-8";

There are several regular at-rules, designated by their identifiers, each with a different syntax:

Nested

@IDENTIFIER (RULE) {

}

A subset of nested statements, which can be used as a statement of a style sheet as well as inside of conditional group rules.

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.

Index

Specifications

Specification
CSS Conditional Rules Module Level 3
Compatibility Standard
# css-at-rules

See also

https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule