0
0
HTMLmarkup~20 mins

Image source and alt attribute in HTML - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Image Alt Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the purpose of the alt attribute
Why is the alt attribute important for an <img> tag in HTML?
AIt provides alternative text for screen readers and shows if the image fails to load.
BIt sets the image size automatically based on the text length.
CIt links the image to another webpage when clicked.
DIt changes the image format from PNG to JPEG.
Attempts:
2 left
💡 Hint
Think about accessibility and what happens if the image cannot be displayed.
📝 Syntax
intermediate
2:00remaining
Correct syntax for image source and alt
Which of the following <img> tags is correctly written with both src and alt attributes?
A<img src="photo.jpg" alt="A beautiful sunrise">
B<img alt="A beautiful sunrise" source="photo.jpg">
C<img src=photo.jpg alt=>
D<img src="photo.jpg" alt>
Attempts:
2 left
💡 Hint
Check attribute names and if values are properly quoted.
rendering
advanced
2:00remaining
What is displayed if image source is broken?
Given this HTML code:
<img src="missing.jpg" alt="Logo image">

What will the browser show if missing.jpg does not exist?
AThe browser will crash with an error.
BNothing will appear; the image area will be empty.
CThe text 'Logo image' will be shown where the image should be.
DA broken image icon with no text will appear.
Attempts:
2 left
💡 Hint
Think about fallback content for images that fail to load.
selector
advanced
2:00remaining
Selecting images with missing alt attributes using CSS
Which CSS selector targets all <img> elements that do NOT have an alt attribute?
Aimg:empty
Bimg[alt='']
Cimg[alt]
Dimg:not([alt])
Attempts:
2 left
💡 Hint
Look for a selector that matches elements missing a specific attribute.
accessibility
expert
2:00remaining
Best practice for decorative images and alt attribute
For purely decorative images that add no information, what is the best way to use the alt attribute to keep the page accessible?
AWrite <code>alt="decorative image"</code> to describe it.
BSet <code>alt=""</code> (empty string) to hide it from screen readers.
COmit the <code>alt</code> attribute entirely.
DUse <code>alt="image"</code> as a generic description.
Attempts:
2 left
💡 Hint
Think about how screen readers treat empty alt attributes.