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
Understanding ID selectors in HTML & CSS
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 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
#idFill in the Blanks
Spot the Error
Student with a class code? Join your class →