Challenge - 5 Problems
ID Attribute Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
What is the purpose of the
id attribute in HTML?Choose the best explanation for what the
id attribute does in an HTML element.Attempts:
2 left
💡 Hint
Think about how you can select one specific element in CSS or JavaScript.
✗ Incorrect
The
id attribute gives a unique name to an element. This helps CSS and JavaScript find exactly that element. Unlike classes, IDs must be unique on the page.📝 Syntax
intermediate1:30remaining
Which HTML snippet correctly uses the
id attribute?Select the HTML code that correctly assigns an
id to a div element.Attempts:
2 left
💡 Hint
Remember the correct way to write attribute values in HTML.
✗ Incorrect
Attribute values should be enclosed in quotes. Option B uses double quotes correctly. Option B misses quotes, C has a missing quote, and D has misplaced quotes.
❓ rendering
advanced2:00remaining
What will be the visible result of this HTML and CSS code?
Given the code below, what color will the text inside the
p tag appear as in the browser?HTML
<style> #unique { color: blue; } p { color: red; } </style> <p id="unique">Hello World</p>
Attempts:
2 left
💡 Hint
Think about CSS specificity and which rule wins.
✗ Incorrect
The CSS rule with the
id selector (#unique) is more specific than the element selector (p), so the text color will be blue.❓ accessibility
advanced1:30remaining
Why is it important to use unique
id attributes for accessibility?Choose the best reason why unique
id values help users who rely on assistive technologies.Attempts:
2 left
💡 Hint
Think about how labels connect to form inputs.
✗ Incorrect
Unique
id attributes let assistive technologies like screen readers connect labels to form controls, improving navigation and understanding.❓ selector
expert1:30remaining
Which CSS selector targets the element with
id="main-content"?Select the CSS selector that will style only the element with
id="main-content".Attempts:
2 left
💡 Hint
Remember how CSS selects elements by ID.
✗ Incorrect
The
# symbol in CSS selects elements by their id. So #main-content targets the element with that exact ID.