Width and height, online
Six activities your students do on their own devices. See who's finished, and their scores.
Width and height in one minute
What students need to know
min-height: 50vh means the section is always at least half the viewport tall. It can grow taller with content but never shorter. width: 100% makes the paragraph as wide as its parent element. On a 600px parent, it becomes 600px.
max-width: 100% sets an upper limit. The image can be its natural size or smaller but never wider than the container. CSS property names are case-sensitive and must be lowercase. 'Width' is invalid — use 'width'.
Mistakes students make
- CSS declarations require a colon. It should be width: 200px; not width 200px;.
- CSS declarations require a colon. It should be height: 150px; not height 150px;.
- There must be no space between the number and the unit. It should be width: 50%; not width: 50 %;.
- There must be no space between the number and the unit. It should be height: 50vh; not height: 50 vh;.
What students will learn in this module
Every question in Module 49
Quick questions
- What does max-width: 100% do on an image?APrevents the image from exceeding its container's widthBStretches the image to always fill its container
- Which property sets the minimum vertical size of an element?Amin-widthBmin-height
- True or false: width: 50% is relative to the viewport width.AFalseBTrue
- True or false: CSS property names like 'Width' with a capital letter are valid.AFalseBTrue
- What does min-width: 200px do?ASets the element's width to exactly 200pxBPrevents the element from being narrower than 200px
Key terms
Students type the meaning of:
max-width
Match the pairs
div {
width: 800px;
max-width: 100%;
}Match it to what it doesimg { max-width: 100%; }Match it to what it doesmin-height prevents an element from being shorter than the specified valueMatch it to what it does% widths are relative to the parent element's width, not the viewportMatch it to what it doesp { widht: 200px; }Match it to what it doesdiv { Width: 300px; }Match it to what it doesFill in the blanks
div { _____: 300px; }Hint: Type the CSS property name that sets the horizontal size of an element
div { ______: 200px; }Hint: Type the CSS property name that sets the vertical size of an element
img { _________: 100%; }Hint: Type the CSS property name that sets the largest size an element is allowed to reach
section { __________: 50vh; }Hint: Type the CSS property name that sets the smallest vertical size an element must be
p { _________: 200px; }Hint: Type the CSS property name that sets the smallest horizontal size an element must be
Spot the error
Question 1
Ap { width 200px; }Bh1 { height: 100px; }Cdiv { width: 50%; }
Question 2
Adiv { width: 300px; }Bimg { height 150px; }Cp { max-width: 600px; }
Question 3
Adiv { max-width: 800px; }Bp { width: 100%; }Cimg { width: 50 %; }
Question 4
Adiv { width: 400px; }Bp { min-height: 100px; }Cimg { max-width: 100%; }Dsection { height: 50 vh; }
Question 5
Ap { width: 100%; }Bdiv { height: 200px; }Cimg { max-width: 100%; }Dsection { min-height: 50vh; }Ea { width: 120 px; }
