Classes and IDs
The class and id attributes let you name elements so CSS and JavaScript can find them.
- A
classcan be reused on many elements - An
idmust be unique on the page, used by one element only
In CSS, you target a class with a dot (.name) and an id with a hash (#name).
Try it yourself
Loading editor…