QamoosTech
FrontendBeginner

Media Query

PronunciationMEE-dee-uh KWEER-ee

Definition

A CSS technique used to apply different styles based on device characteristics like screen width, height, or resolution.

Where you hear it

In frontend development meetings, CSS styling sessions, and responsive design reviews.

Examples

  • We use a media query to change the navigation menu layout on mobile screens.
  • This media query detects if the user has enabled dark mode in their system preferences.
  • Below 768 pixels, the media query switches the grid to one column.

Common mistake

Thinking media queries can only check screen width, when they can also target device orientation, pixel density, and input types like touch versus mouse.

Don't confuse with

Media queries are often confused with container queries; while media queries respond to the entire viewport size, container queries respond to the size of a specific parent element.

Say it at work

  • In a meeting or chatCan you add a media query to fix the layout shift we're seeing on tablets?
  • In an email or ticketI have updated the CSS file with a new media query to ensure the dashboard remains readable on smaller screens.