Challenge - 5 Problems
Background Image Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate2:00remaining
What is the visible background color when this CSS is applied?
Given the CSS below, what color will you see as the background of the <body> element if the image URL is invalid or missing?
CSS
body {
background-image: url('nonexistent.jpg');
background-color: #ffcc00;
}Attempts:
2 left
💡 Hint
Think about what happens when a background image cannot load but a background color is set.
✗ Incorrect
When the background image fails to load, the browser shows the background color instead. Here, #ffcc00 is a yellow shade, so the background appears yellow.
❓ selector
intermediate2:00remaining
Which CSS selector applies the background image only to <section> elements with class 'hero'?
Choose the CSS selector that correctly applies a background image only to <section> elements that have the class 'hero'.
Attempts:
2 left
💡 Hint
Remember that the class selector comes immediately after the element name with no space to target that element with the class.
✗ Incorrect
The selector 'section.hero' targets <section> elements that have the class 'hero'. Other options select different elements or combinations.
🧠 Conceptual
advanced2:00remaining
What does the CSS property 'background-size: cover;' do?
Select the correct description of what 'background-size: cover;' does to a background image.
Attempts:
2 left
💡 Hint
Think about how the image fits inside the container without distortion.
✗ Incorrect
'background-size: cover;' scales the image to fill the container completely while keeping its proportions. Parts may be cropped if the aspect ratios differ.
❓ accessibility
advanced2:00remaining
Which practice improves accessibility when using background images for important content?
When a background image contains important information, which approach improves accessibility for screen readers?
Attempts:
2 left
💡 Hint
Think about how screen readers access content and what they can read.
✗ Incorrect
Screen readers cannot read CSS background images. Important content must be in HTML text or ARIA labels for accessibility.
📝 Syntax
expert2:00remaining
What error does this CSS code cause?
Consider the CSS below. What error or issue will occur when the browser tries to apply it?
CSS
div {
background-image: url('image.png') no-repeat center center;
}Attempts:
2 left
💡 Hint
Check which CSS property accepts multiple values and which does not.
✗ Incorrect
'background-image' only accepts a URL or image function. Properties like 'background-repeat' and 'background-position' handle repeat and position separately. Combining them in 'background-image' causes a syntax error.