interface
Mediaquerylist — CSS reference
MediaQueryList exposes the serialized media query and its current boolean match result. Its change event is dispatched when the match status changes. Modern code uses addEventListener rather than the legacy addListener method.
Formal Syntax & Structure
css syntaxcss
const list = matchMedia("(min-width: 600px)"); list.matches;Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>MediaQueryList</title><style>body{margin:0}#a{padding:8px;background:rgb(232,237,241);color:rgb(0,0,0);box-sizing:border-box}
</style><body><main id="a">Resize the viewport to explore this example.</main><script>const list=matchMedia("(min-width:600px)");a.textContent=list.media+": "+list.matches;</script></body></html>