Class selectors
A CSS selector that targets every element whose class attribute matches classname, written with a leading dot
Understanding Class selectors in HTML & CSS
What it does: Unlike an ID, the same class name can appear on multiple elements, making it ideal for shared styles. A dot starts a class selector. A hash starts an ID selector. Chaining a type and class selector with no space restricts the match to elements satisfying both conditions. A single class attribute can hold multiple class names separated by spaces. The dot is CSS syntax. In HTML you write class="classname" with no dot in the attribute value.
Common mistakes: The class attribute value must not include the dot. Write class="note" not class=".note". The dot is CSS syntax used only in the selector, not in the HTML attribute. The background declaration is missing a semicolon. It should be background: navy; — every CSS declaration must end with a semicolon.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 31–41) and word search (Modules 21–41).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
.classnameFill in the Blanks
Spot the Error
Student with a class code? Join your class →