Media Query
A media query is a CSS feature that applies styles only when certain conditions are met, most often the width of the screen. It is the main tool for making pages responsive.
Web
With @media you can write rules that kick in only on small phones, large desktops, or in dark mode. This lets one stylesheet adapt a layout to many screen sizes.
A common approach is mobile-first: write base styles for small screens, then use min-width media queries to layer on changes for larger screens.
Examples
CSS
@media (max-width: 600px) {
.sidebar {
display: none;
}
}Output:
Hides the sidebar on screens 600px wide or narrower.