Example using Tags, IDs and Classes
This paragraph is styled using the p selector.
The Header, Menu and Footer are styled using IDs.
This paragraph uses class .highlight
Another element using the same class.
This paragraph has FOUR classes.
Blue + Bold
Red + Big
The class .shadow can be reused on any element.
This selector is:
p.highlight
The selector used is:
div#menu
This text is RED because the ID selector has higher priority than the class selector.
| Selector | Example | Description |
|---|---|---|
| Tag | p | Styles every paragraph |
| ID | #header | Styles one unique element |
| Class | .card | Reusable style |
| Tag + Class | p.highlight | Only highlighted paragraphs |
| Tag + ID | div#menu | Specific div with id="menu" |