0
0
CSSmarkup~20 mins

Media queries in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Media Query Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
Identify the correct syntax for a media query targeting screens wider than 600px
Which of the following CSS snippets correctly applies styles only when the screen width is greater than 600 pixels?
A@media screen and (min-width: 600px) { body { background: blue; } }
B@media screen and (max-width: 600px) { body { background: blue; } }
C} } ;eulb :dnuorgkcab { ydob { )xp006 :htdiw-nim( dna neercs aidem@
D@media (min-width: 600px) { body { background: blue; } }
Attempts:
2 left
💡 Hint
Remember that min-width means 'at least this width' and the syntax requires parentheses around the condition.
🧠 Conceptual
intermediate
2:00remaining
What does this media query do?
Consider this CSS media query:
@media (max-width: 480px) { p { font-size: 1.2rem; } }

What is the effect of this media query?
AIt increases the font size of paragraphs only on screens 480px wide or smaller.
BIt increases the font size of paragraphs only on screens wider than 480px.
CIt decreases the font size of paragraphs on all screen sizes.
DIt applies the font size change only on screens exactly 480px wide.
Attempts:
2 left
💡 Hint
max-width means 'up to and including' the specified width.
layout
advanced
2:00remaining
How does this media query affect layout?
Given this CSS:
div.container { display: flex; flex-direction: row; } @media (max-width: 700px) { div.container { flex-direction: column; } }

What happens to the layout when the screen width is 650px?
AThe container becomes hidden because flex-direction is invalid.
BThe container's children stay in a row because max-width does not apply.
CThe container's children stack vertically because flex-direction changes to column.
DThe container's children stack horizontally with extra space.
Attempts:
2 left
💡 Hint
max-width: 700px applies to widths 700px and below.
accessibility
advanced
2:00remaining
Which media query helps improve accessibility for users with low vision?
Which media query is best suited to increase text size for users who prefer larger fonts on their devices?
A@media (min-resolution: 2dppx) { body { font-size: 2rem; } }
B@media (hover: none) { body { font-size: 2rem; } }
C@media (prefers-reduced-motion: reduce) { body { font-size: 2rem; } }
D@media (prefers-contrast: more) { body { font-size: 2rem; } }
Attempts:
2 left
💡 Hint
Look for media features related to contrast or visual preferences.
rendering
expert
2:00remaining
What is the background color when screen width is 800px?
Given this CSS:
body { background-color: white; } @media (min-width: 600px) and (max-width: 900px) { body { background-color: lightgray; } } @media (min-width: 850px) { body { background-color: darkgray; } }

What background color will the body have when the screen width is exactly 800px?
Awhite
Blightgray
Ctransparent
Ddarkgray
Attempts:
2 left
💡 Hint
Check which media queries apply at 800px and which override others.