CSS Selectors
A selector decides which elements a rule applies to. The three you use most:
- Type — by tag name:
p { }styles every paragraph. - Class — by a
classattribute, with a dot:.note { }. Reusable on many elements. - Id — by a unique
id, with a hash:#header { }. One per page.
.highlight { background: yellow; }
#title { color: green; }
Try it yourself
Loading editor…