0
0
HTMLmarkup~20 mins

Attribute best practices in HTML - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Attribute Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why use semantic attributes in HTML?
Which of the following is the main benefit of using semantic attributes like alt on images?
AThey improve accessibility by describing images for screen readers.
BThey allow images to be draggable by default.
CThey change the image color automatically based on user preference.
DThey make images load faster by compressing them.
Attempts:
2 left
💡 Hint
Think about users who cannot see images.
📝 Syntax
intermediate
2:00remaining
Correct syntax for boolean attributes
Which option shows the correct way to write the boolean attribute disabled on a button in HTML5?
A<button disabled="">Click me</button>
B<button disabled="false">Click me</button>
C<button disabled>Click me</button>
D<button disabled="true">Click me</button>
Attempts:
2 left
💡 Hint
Boolean attributes do not need a value to be true.
rendering
advanced
2:00remaining
Effect of missing required attribute
What will happen if the src attribute is missing from an <img> tag?
HTML
<img alt="A cat">
AThe browser automatically loads a default image.
BThe browser shows a broken image icon or nothing.
CThe browser displays the alt text as an image.
DThe browser crashes or stops rendering the page.
Attempts:
2 left
💡 Hint
Think about what the browser needs to show an image.
selector
advanced
2:00remaining
Selecting elements by attribute in CSS
Which CSS selector targets all <input> elements with a type attribute equal to "checkbox"?
AAll of the above
Binput[type="checkbox"]
Cinput[type='checkbox']
Dinput[type=checkbox]
Attempts:
2 left
💡 Hint
Attribute selectors can use quotes or no quotes around values.
accessibility
expert
3:00remaining
Best practice for ARIA attributes
Which statement about ARIA attributes is correct?
AARIA attributes are only needed for visual styling purposes.
BARIA attributes can replace native HTML elements for better accessibility.
CARIA attributes should be added to all elements regardless of their role.
DARIA attributes should be used to add semantic meaning only when native HTML elements do not provide it.
Attempts:
2 left
💡 Hint
Think about when ARIA is necessary versus native HTML.