ID selectors
A CSS selector that targets one unique element by matching its id attribute; written as a hash symbol followed by the id value
What it does: Each id value may appear only once per HTML document; this element correctly uses a unique id. The ID selector #box overrides competing class or element rules due to its higher specificity score. ID selectors start with # followed by the id value. A dot (.) is used for class selectors. An ID selector outweighs any number of class selectors in the cascade. The hash and the id name must be written together with no space: #title. #intro targets the element whose id attribute equals "intro". Hyphens are perfectly valid in id names and selectors. #main-content is common and correct.
Common mistakes: The selector .hero uses a dot (class selector). To target id="hero" it should be #hero { color: red; }. The opening curly brace is missing. It should be #banner { color: gold; }.
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
#idFill 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 →