0
0
HTMLmarkup~20 mins

ID attribute in HTML - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ID Attribute Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1: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.
AIt defines the type of content inside the element.
BIt groups multiple elements together to apply the same style.
CIt uniquely identifies an element on the page so it can be styled or accessed easily.
DIt hides the element from the page.
Attempts:
2 left
💡 Hint
Think about how you can select one specific element in CSS or JavaScript.
📝 Syntax
intermediate
1:30remaining
Which HTML snippet correctly uses the id attribute?
Select the HTML code that correctly assigns an id to a div element.
A<div id=header"Welcome</div>
B<div id="header">Welcome</div>
C<div id='header'>Welcome</div>
D<div id=header>Welcome</div>
Attempts:
2 left
💡 Hint
Remember the correct way to write attribute values in HTML.
rendering
advanced
2: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>
AThe text will be blue.
BThe text will be red.
CThe text will be black (default).
DThe text will be both red and blue, overlapping.
Attempts:
2 left
💡 Hint
Think about CSS specificity and which rule wins.
accessibility
advanced
1: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.
AThey hide content from keyboard users.
BThey make the page load faster.
CThey automatically translate the page content.
DThey allow screen readers to link labels and controls correctly.
Attempts:
2 left
💡 Hint
Think about how labels connect to form inputs.
selector
expert
1: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".
A#main-content
B*main-content
C.main-content
Dmain-content
Attempts:
2 left
💡 Hint
Remember how CSS selects elements by ID.