Backgrounds, online
Six activities your students do on their own devices. See who's finished, and their scores.
Backgrounds in one minute
What students need to know
The rgba function sets Red, Green, Blue, and an Alpha transparency layer between 0 and 1. background-position: center automatically aligns the graphic vertically and horizontally.
The background shorthand combines color, image, position, size, and repeat into a single line. CSS uses the url() function to point to image sources for backgrounds.
Mistakes students make
- Line 1 is incorrect because background-image values must be wrapped inside a url() function, not as a raw string.
- Line 2 is incorrect because repeat-yes is invalid. Use repeat, no-repeat, repeat-x, or repeat-y.
- Line 0 has invalid syntax; remove the colon following the class name '.main'.
- Line 1 is incorrect. cover-all is invalid; use cover to scale the image proportionally.
What students will learn in this module
Every question in Module 58
Quick questions
- Which property is a shorthand that can set color, image, and repeat values all at once?AbackgroundBbackground-style
- How should a background image file path be specified inside CSS?Asrc('image.jpg')Burl('image.jpg')
- Which value ensures a background image stretches proportionally to completely fill its container?AcoverBcontain
- Does a background-color render underneath or on top of a background-image?AOn top of the imageBUnderneath the image
- What is the default behavior of a background image if it is smaller than its container element?AIt repeats to tile the containerBIt stretches automatically
Key terms
Students type the meaning of:
background
Match the pairs
.box {
background-repeat: no-repeat;
}Match it to what it does.banner {
background-size: contain;
}Match it to what it doesSets a background color using a semi-transparent alpha channel value.Match it to what it doesPositions a background image to sit exactly in the middle of its bounding layout block.Match it to what it does.alert {
background-image: 'bg.png';
}Match it to what it does.hero {
background-size: cover-all;
}Match it to what it doesFill in the blanks
.box { ________________: red; }Hint: Type the property used to change the background color
.card { ________________: url('img.png'); }Hint: Type the property used to add a background image
.hero { background-repeat: _________; }Hint: Type the value that prevents background images from repeating
.header { background-size: _____; }Hint: Type the value that stretches a background image to fully cover the element
.main { ___________________: center; }Hint: Type the property used to align the background image position
Spot the error
Question 1
A.banner {B background-image: 'bg.jpg';C background-color: blue;D}
Question 2
A.section {B background-color: #fff;C background-repeat: repeat-yes;D}
Question 3
A.main: {B background: url('pattern.png') repeat-x;C padding: 20px;D}
Question 4
A.header {B background-size: cover-all;C background-position: center;D}
Question 5
A.card {B background-color: transparent;C background-positioning: top left;D}
