Skip to content
techsnow

CSS Selectors

Basic Selectors

Selectors decide which elements a rule applies to.

SelectorExampleSelects
ElementpEvery <p>
Class.cardEvery element with class="card"
ID#topThe element with id="top"
Universal*Every element
Grouph1, h2, h3All three
Combinedp.noteOnly <p> elements with class note
p { line-height: 1.6; }
.card { padding: 20px; border-radius: 12px; }
#top { background: navy; }
* { box-sizing: border-box; }
h1, h2, h3 { font-family: Georgia, serif; }
button.primary { background: teal; color: white; }