Media queries (responsive design), online
Six activities your students do on their own devices. See who's finished, and their scores.
Media queries (responsive design) in one minute
What students need to know
The landscape orientation keyword matches devices where viewport width exceeds height dimensions. The and keyword strings screen target constraints alongside specific feature conditions.
@media is a rule built directly into CSS to control conditional layouts. max-width applies styles if the viewport width is less than or equal to the defined value.
Mistakes students make
- Line 0 is incorrect because it is missing the mandatory @ character at the beginning of media.
- Line 1 is incorrect because CSS properties inside a media query block must use colons (:), not equals signs (=).
- Line 2 is incorrect because the colon separating the display property and its value is missing.
- Line 3 is incorrect because the trailing word pixels is invalid syntax after a closing brace.
What students will learn in this module
Every question in Module 60
Quick questions
- Is @media a native CSS rule or an HTML layout tag?AHTML tagBCSS rule
- Which media feature targets screens smaller than or equal to a specific width dimension?Amin-widthBmax-width
- Which character tokens must wrap a media feature condition like max-width: 768px?AParentheses ( )BSquare brackets [ ]
- What condition does @media (orientation: portrait) evaluate?AViewport height is greater than or equal to widthBViewport width is greater than height
- Can you join multiple media query conditions together using the 'and' logical keyword?AYesBNo
Key terms
Students type the meaning of:
@media
Match the pairs
@media (max-width: 600px) {
.box { display: none; }
}Match it to what it does@media (min-width: 1024px) {
body { font-size: 18px; }
}Match it to what it doesA responsive design rule that applies specific styles when a device is held horizontally.Match it to what it doesCombines screen type and a maximum width condition to style mobile devices.Match it to what it does@media max-width: 768px {
p { color: blue; }
}Match it to what it doesmedia (min-width: 480px) {
h1 { font-size: 2rem; }
}Match it to what it doesFill in the blanks
______ (max-width: 600px) { body { color: red; } }Hint: Type the keyword that initiates a media query rule
@media (***: 768px) { .nav { display: block; } }Hint: Type the feature used to target screens wider than a minimum width
@media (***: 480px) { .sidebar { display: none; } }Hint: Type the feature used to target screens narrower than a maximum width
@media ______ and (max-width: 900px) { .card { width: 50%; } }Hint: Type the media type keyword representing digital screens
@media (orientation: _________) { .hero { height: 100vh; } }Hint: Type the orientation mode that targets screens wider than they are tall
Spot the error
Question 1
Amedia (max-width: 700px) {B .box { width: 100%; }C}
Question 2
A@media (max-width: 600px) {B .container { width = 100%; }C}
Question 3
A@media (min-width: 768px) {B .nav {C display flex;D }E}
Question 4
A@media (min-width: 800px) {B .grid {C display: grid;D } pixelsE}
Question 5
A@media screen-only and (max-width: 500px) {B body { background: white; }C}
