CSS selectors
A selector chooses which HTML elements a CSS rule will style.
What you will learn
- How element, class, and ID selectors work
- How to select related elements
Minimal example
.notice { color: darkblue; } main p { line-height: 1.8; }The first rule selects elements with class="notice". The second selects paragraphs inside main.
Common mistakes
- Class selectors start with
.; ID selectors start with#. - Specificity and source order affect which matching rule wins.