0
0
HTMLmarkup~20 mins

Image tag usage in HTML - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Image Tag Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the purpose of the alt attribute in an tag?
Why should you always include the alt attribute in an <img> tag?
AIt adds a border around the image for styling purposes.
BIt provides alternative text for screen readers and shows text if the image fails to load.
CIt links the image to another webpage when clicked.
DIt changes the image size automatically based on screen width.
Attempts:
2 left
💡 Hint
Think about accessibility and what happens if the image cannot be displayed.
📝 Syntax
intermediate
1:30remaining
Which tag is correctly written to display an image?
Choose the correct <img> tag syntax that will display an image located at "images/photo.jpg" with alt text "A photo".
A<img src="images/photo.jpg" alt="A photo">
B<img href="images/photo.jpg" alt="A photo">
C<img src="images/photo.jpg" alt=>
D<img src="images/photo.jpg" alt="">
Attempts:
2 left
💡 Hint
Remember the attribute that specifies the image file location is src.
rendering
advanced
2:00remaining
What will the browser display for this image tag?
Given this HTML code:
<img src="missing.jpg" alt="Missing image">

What will the browser show if the file "missing.jpg" does not exist?
AThe browser will display a broken image icon with no text.
BNothing will be shown; the image area will be blank.
CThe browser will crash or freeze.
DThe text "Missing image" will be shown where the image should be.
Attempts:
2 left
💡 Hint
Think about what the alt text is for when the image cannot load.
selector
advanced
1:30remaining
Which CSS selector targets all images inside a
element?
You want to style all <img> tags that are inside any <section> element. Which CSS selector should you use?
Asection img
Bimg > section
Csection > img
Dimg.section
Attempts:
2 left
💡 Hint
Think about how to select elements nested inside another element.
accessibility
expert
2:00remaining
Which practice improves accessibility for decorative images?
You have an image used only for decoration and it adds no information. How should you write the <img> tag to improve accessibility?
A<img src="decorative.png" aria-hidden="false">
B<img src="decorative.png">
C<img src="decorative.png" alt="">
D<img src="decorative.png" alt="decorative image">
Attempts:
2 left
💡 Hint
Think about how screen readers treat empty alt attributes.