Knowledge Maxxing
← Back to topic library
Dev MaxxingBeginnerHTML and CSS60 sec

CSS selector

A CSS selector is a pattern that identifies which HTML elements a set of style rules should apply to.

Prerequisite: HTML element

What matters

Choosing the right selector determines exactly which elements get styled, and overly broad or narrow selectors are a common source of unexpected styling bugs.

Example

The selector '.button' applies its styles to every element with class 'button', while '#submit' applies only to the one element with id 'submit'.

Common misconception

A CSS selector does not always target just one element; class and tag selectors commonly match many elements at once.

Recall question

What does a CSS selector actually determine?

Keywords and related concepts

CSS selectorstylingtargeting elementscss specificity

Related topics

CSS specificity
Dev MaxxingBeginner
HTML element
Dev MaxxingBeginner