The id attribute
An HTML attribute that gives an element a unique identifier on the page. No two elements may share the same id value.
What it does: Both elements have different id values: wrapper and content. This is correct - every id on the page must be unique. about-us uses a hyphen to separate words. This is valid. A space like id="about us" would be invalid. id values cannot contain spaces. Use hyphens or underscores to separate words: main-heading or main_heading. id values are case-sensitive. Header and header are treated as different identifiers. Like all attributes, id goes in the opening tag only. Closing tags must not contain attributes. id is used by CSS (#id-name) and JavaScript (getElementById) to select and manipulate a specific element. Spaces are not allowed in id values. Use a hyphen or underscore instead: id="my-id" or id="my_id".
Common mistakes: id values cannot contain spaces. Use a hyphen or underscore instead: id="main-title" or id="main_title". HTML attribute names must be lowercase. ID with a capital letter is non-standard. The correct form is id="main-nav".
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 →