Class selectors
A CSS selector that targets every element whose class attribute matches classname, written with a leading dot
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 journey and assign it to your class.
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
Create a free class, add this module to a journey, and track who's stuck.
Create a free teacher account →No credit card. No setup fee. Make a class and invite students in under three minutes.
Practice this topic interactively, track progress, and unlock badges.
Start Learning Free →