Media query
A media query is a CSS technique that applies different styles to a website or an app based on the characteristics of the device displaying it, such as screen size, resolution, and browser viewport.
Media queries in CSS allow developers to create responsive web designs that adapt to different devices, improving accessibility and the user experience.
Web developers and designers leverage media queries to define specific rules for different breakpoints, which are specific screen widths at which the design and layout change. These queries allow a website to adjust its layout, typography, and other design elements to deliver an optimal viewing and user experience regardless of device.
Media queries are made of optional media types and media features. You can combine types and features to define the device category and other specific characteristics, such as aspect ratio, color, and resolution.
For example, the hover feature allows a media query to check if the device enables specific elements to hover over other elements.
Check out our in-depth guide on media queries and breakpoints to learn the basics of responsive web design.