Should media queries use width or device-width?

Responsive media queries should use width or modern range syntax, not device-width. The width feature describes the current viewport available to the page, which changes when a browser window is resized, split or zoomed. That is the space the layout must fit.
Device width describes the output device and does not describe the browser’s current content area and is deprecated in Media Queries Level 4. A large monitor can contain a narrow browser window, while a tablet can show two apps side by side. Device-based queries miss both situations.
Use content-driven conditions such as:
@media (min-width: 48rem) {
.layout { grid-template-columns: 2fr 1fr; }
}
@media (width >= 48rem) {
.layout { grid-template-columns: 2fr 1fr; }
}
The two examples express the same lower-bound idea with classic and range syntax. Choose syntax supported by the project and keep a consistent convention. Use hover, pointer, orientation or resolution features only when the design truly depends on those capabilities, not as indirect device detection.
Test resizable desktop windows, mobile orientation and embedded contexts. For reusable components in sidebars or grids, even viewport width can be too broad; a container query can respond to the component’s assigned inline size more accurately. Keep the rule beside the component it controls and document the reason for the threshold or constraint. This makes future changes easier to evaluate and prevents an unrelated page stylesheet from silently overriding the responsive behavior. Test the solution with keyboard focus, touch input and a resized desktop window. Responsive geometry is only successful when every visible control remains reachable and the content keeps a logical reading order.