0
0
CSSmarkup~20 mins

Background size in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Background Size Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
rendering
intermediate
2:00remaining
What is the visual result of this CSS?
Given the CSS below applied to a 200px by 200px div with a 100px by 100px background image, what will the background look like?
CSS
div {
  width: 200px;
  height: 200px;
  background-image: url('image.png');
  background-size: 50% 50%;
  background-repeat: no-repeat;
  background-position: center;
}
AThe background image is stretched to fill the entire 200px by 200px div.
BThe background image is scaled to 100px by 100px and centered inside the div.
CThe background image is shown at its original size 100px by 100px at the top-left corner.
DThe background image is tiled repeatedly to fill the div.
Attempts:
2 left
💡 Hint
Remember that 50% 50% means half the width and half the height of the container.
📝 Syntax
intermediate
1:30remaining
Which CSS rule correctly sets the background image to cover the entire element?
Choose the correct CSS background-size value to make the background image cover the entire element without distortion.
Abackground-size: cover;
Bbackground-size: 100% 100%;
Cbackground-size: contain;
Dbackground-size: auto;
Attempts:
2 left
💡 Hint

One value makes the image cover the entire area, cropping if needed.

selector
advanced
1:30remaining
Which CSS selector applies the background-size only to images inside a container with class hero?
You want to apply background-size: contain; only to img elements inside a container with class hero. Which selector is correct?
A#hero img { background-size: contain; }
Bimg.hero { background-size: contain; }
Chero img { background-size: contain; }
D.hero img { background-size: contain; }
Attempts:
2 left
💡 Hint
Remember that classes start with a dot and IDs with a hash.
🧠 Conceptual
advanced
1:30remaining
What happens if you set background-size: auto; on an element?
Choose the correct description of the effect of background-size: auto; on the background image.
AThe background image keeps its original size.
BThe background image stretches to fill the element.
CThe background image scales to fit the element's width.
DThe background image is hidden.
Attempts:
2 left
💡 Hint
Think about what 'auto' means in CSS sizing.
accessibility
expert
2:00remaining
How does improper use of background-size affect accessibility?
Which of the following is a potential accessibility issue caused by incorrect background-size usage?
ABackground images with <code>background-size</code> cause screen readers to crash.
BUsing <code>background-size</code> disables keyboard navigation.
CBackground images scaled too small may make text unreadable if text overlays the image.
DBackground images always improve accessibility regardless of size.
Attempts:
2 left
💡 Hint
Think about how background images interact with text visibility.