Skip to content

Courses / CSS3 Mastery: Beginner to Advanced / Media Queries

2,092 people viewed this

Media Queries

@media print {
  nav, .no-print {
    display: none;
  }
  body {
    color: black;
    background: white;
  }
}

Print media queries help remove unnecessary interface controls and improve printed readability.

Practice Exercise

Create a responsive navigation bar, a print stylesheet and a reduced-motion alternative. Test the rules using browser DevTools.

Quiz — 10 MCQs

  1. What does @media do? (A) Applies conditional styles (B) Creates HTML tags (C) Defines a database (D) Imports JavaScript. Answer: A. It applies CSS under matching media conditions.
  2. What does min-width: 768px mean? (A) Viewport width is at least 768 CSS pixels (B) Element height is 768px (C) Font size is 768px (D) Width is always fixed. Answer: A. It tests the viewport width threshold.
  3. How should breakpoints usually be chosen? (A) Based on where the layout needs adjustment (B) Only from device brand names (C) Randomly (D) Always at one universal value. Answer: A. Content-driven breakpoints avoid unnecessary device-specific assumptions.
  4. Which feature checks whether hover is available? (A) hover (B) pointer-color (C) font-hover (D) grid-hover. Answer: A. The hover media feature describes hover capability.
  5. What does pointer: coarse commonly indicate? (A) A less precise primary pointing mechanism (B) A large font (C) A fixed width (D) An image filter. Answer: A. Coarse pointer input is common on touch devices.
  6. What does @supports test? (A) Support for a CSS declaration or feature condition (B) User password validity (C) Server uptime (D) HTML title length. Answer: A. Feature queries conditionally apply styles based on support.
  7. Which query respects a user's reduced-motion preference? (A) prefers-reduced-motion (B) prefers-blue (C) hover: reduce (D) screen-size: slow. Answer: A. It exposes the reduced-motion preference.
  8. Which media type is useful for printed pages? (A) print (B) database (C) audio-only (D) source. Answer: A. Print styles can simplify printed documents.
  9. Does orientation: landscape guarantee a physical device is held horizontally? (A) Yes (B) No (C) Only on phones (D) Only with JavaScript. Answer: B. It describes the viewport's aspect orientation.
  10. Can a website use multiple media queries? (A) Yes (B) No (C) Only one per file (D) Only with Grid. Answer: A. Multiple queries can target different conditions.

Key Takeaways

  • Media queries adapt styling to viewport and input conditions.
  • Choose breakpoints based on content, not specific device models.
  • Use feature queries, print styles and reduced-motion preferences appropriately.

Rate this course

No ratings yet — yours can be the first.

Stars show on this course. Your written note stays private.

Your stars