HTML attributes
Extra information added to an HTML opening tag as a name="value" pair, such as class="header" or href="page.html".
Understanding HTML attributes in HTML & CSS
What it does: id="main-title" follows the name="value" format. It is placed inside the <h1> opening tag. Three attributes are listed in the opening tag, each separated by a space - no commas or other separators. Attributes always go in the opening tag, never in the closing tag. For example: <p class="note"> not </p class="note">. Attribute values must be wrapped in double quotes. class="header" is correct; class=header without quotes is invalid. href is used on <a> elements to specify the destination URL. src is used on <img> and <script> elements. class="intro" is an attribute that assigns the CSS class 'intro' to the paragraph element.
Common mistakes: The attribute value must be wrapped in double quotes. The correct form is class="intro" not class=intro without quotes. There must be no spaces around the equals sign in an attribute. The correct form is class="main" not class = "main" with spaces.
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 11–21) and word search (Modules 1–23).
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
attributeFill in the Blanks
Spot the Error
Student with a class code? Join your class →