Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A CSS ruleset is a selector (or selector list) followed by a declaration block. The selector identifies which elements the styles target; the declarations inside the braces specify the styles. The word “rule” is often used as a synonym for “ruleset,” but it can be imprecise because CSS also has at-rules such as @media.

How to read a CSS ruleset

.card, .panel {
  color: rebeccapurple;
  margin-block: 1rem;
}
  • .card, .panel is a selector list: it targets elements matching either class selector.
  • color and margin-block are properties; rebeccapurple and 1rem are their values.
  • color: rebeccapurple and margin-block: 1rem are declarations: each pairs a property with a value.
  • The content between the braces is the declaration block.
  • The selector list together with the declaration block makes the complete ruleset.

MDN describes a ruleset as a selector list and its associated declaration block, often called a rule (MDN CSS syntax). The W3C CSS 2.2 specification uses “rule set” and defines it as a selector followed by a declaration block (W3C CSS 2.2 selector syntax).

CSS terminology at a glance

Term What it means Example
Property The styling feature being set. color
Value The setting assigned to a property. rebeccapurple
Declaration A property-value pair, usually written with a colon. color: rebeccapurple
Declaration block The brace-delimited part containing declarations. { color: rebeccapurple; }
Selector A pattern that matches elements to receive styles. .card
Selector list Two or more selectors separated by commas. .card, .panel
Ruleset A selector or selector list paired with a declaration block. .card { color: rebeccapurple; }
Statement A broader CSS syntax unit; rulesets and at-rules are kinds of statements. A ruleset or @media rule
At-rule A statement that begins with @ and a name. @media, @import

Selectors can include type, class, ID, attribute, pseudo-class, pseudo-element, universal, and other forms. Combinators express relationships between selector parts, such as descendant or child relationships. MDN describes selectors as patterns used in CSS rules to target elements (MDN CSS selectors).

Is a CSS rule the same as a ruleset?

In ordinary usage, yes: “rule” often means a selector plus its declaration block. “Ruleset” is the more precise term for that structure. But “rule” is also sometimes used loosely for any CSS instruction, so it is better to distinguish rulesets from at-rules when explaining a stylesheet.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Are at-rules part of a ruleset?

No. An at-rule is a separate kind of CSS statement, identified by an at-sign and a name. For example, @import brings in a stylesheet, @font-face describes a font, and @media applies conditional grouping. A group at-rule such as @media can contain nested statements, including rulesets, but the at-rule itself is not a ruleset. See MDN’s at-rule reference.

Why might a CSS rule be ignored?

A selector must parse as valid CSS for its associated declaration block to apply. For example, this grouped selector contains a typo:

.card, .panle {
  color: rebeccapurple;
}

If .panle is invalid in the relevant selector context, the grouped selector may be invalid as a whole, so the browser can ignore the ruleset rather than applying its declarations to .card. MDN notes this consequence for grouped selectors (MDN CSS syntax). Some newer selector functions have specialized forgiving parsing behavior, so the exact result can depend on the selector feature being used.

The W3C CSS 2.2 specification states that when a user agent cannot parse a selector as valid CSS 2.2, it must ignore that selector and its following declaration block (W3C CSS 2.2 selector syntax). For a rule that appears ineffective, check that the selector is spelled correctly and valid, then verify that the intended element actually matches it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How declaration-block punctuation works

Declarations are separated by semicolons, and the block is enclosed by matching braces. The last declaration may omit its trailing semicolon, but keeping it makes later edits less error-prone.

.notice {
  color: navy;
  padding: 1rem;
}

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.