media-feature

Width — CSS reference

The width range feature tests the width of the output viewport in continuous media (including a rendered scrollbar if present), or page box in paged media. It is not the width of an individual component or physical device.

Formal Syntax & Structure

css syntaxcss
@media (width >= 600px) { /* conditional declarations */ }

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>width</title><style>body{margin:0}#a{padding:8px;background:rgb(232,237,241);color:rgb(0,0,0);box-sizing:border-box}@media (width >= 600px) {#a{color:rgb(0,100,0)}}</style><body><main id="a">Resize the viewport to explore this example.</main></body></html>
CSS Reference