Active Media Queries

You can test these yourself in your browser's developer tools. Try using 'window.matchMedia("(min-width: 10px)").matches' in the console.

Event listeners are added to the MediaQueryList objects to automatically update the display when the media query changes.

Lengths are expressed in different units. It is possible to determine if the viewport is zoomed by comparing em units to px units. The px unit should be 16 times larger than the em unit when the viewport is zoomed to 100%.

@media print /* unsupported */
@media screen /* unsupported */
@media print
@media screen

The output device type. MDN

@media (any-hover) /* unsupported */
@media (any-hover: hover)
@media (any-hover: none)

Can the user hover over elements? This can match multiple queries. MDN

@media (any-pointer) /* unsupported */
@media (any-pointer: coarse)
@media (any-pointer: fine)
@media (any-pointer: none)

Is there a pointing device? How accurate is it? This can match multiple queries. MDN

@media (aspect-ratio) JavaScript Required

The width-to-height aspect ratio of the viewport. This is converted to a decimal number, e.g. 16/9 becomes 1.77778. MDN

@media (color) JavaScript Required

Number of bits of color. MDN

@media (color-gamut) /* unsupported */
@media (color-gamut: p3)
@media (color-gamut: rec2020)
@media (color-gamut: srgb)

Color range supported for output. MDN

@media (color-index) JavaScript Required

Number of indexed colors for display. MDN

@media (device-aspect-ratio) JavaScript Required

DEPRECATED - Width-to-height aspect ratio of output. MDN

@media (device-height) JavaScript Required
@media (device-height) JavaScript Required

DEPRECATED - Output device height. MDN

@media (device-posture) /* unsupported */
@media (device-posture: continuous)
@media (device-posture: folded)

If viewport is flat or folded. MDN

@media (device-width) JavaScript Required
@media (device-width) JavaScript Required

DEPRECATED - Output device width. MDN

@media (display-mode) /* unsupported */
@media (display-mode: browser)
@media (display-mode: fullscreen)
@media (display-mode: minimal-ui)
@media (display-mode: picture-in-picture)
@media (display-mode: standalone)
@media (display-mode: window-controls-overlay)

How the application is being displayed. MDN

@media (dynamic-range) /* unsupported */
@media (dynamic-range: high)
@media (dynamic-range: standard)

The combination of brightness, contrast ratio, and color depth. MDN

@media (forced-colors) /* unsupported */
@media (forced-colors: active)
@media (forced-colors: none)

Does the user agent restrict colors? MDN

@media (grid) /* unsupported */
@media (grid: 0)
@media (grid: 1)

Does the device use a grid or a bitmap screen? MDN

@media (height) JavaScript Required
@media (height) JavaScript Required

The output device height. MDN

@media (hover) /* unsupported */
@media (hover: hover)
@media (hover: none)

Can the user hover over elements? MDN

@media (inverted-colors) /* unsupported */
@media (inverted-colors: inverted)
@media (inverted-colors: none)

Is the user agent or OS inverting colors? MDN

@media (monochrome) JavaScript Required

Bits per pixel in the device's monochrome frame buffer. MDN

@media (orientation) /* unsupported */
@media (orientation: landscape)
@media (orientation: portrait)

Viewport orientation. MDN

@media (overflow-block) /* unsupported */
@media (overflow-block: none)
@media (overflow-block: optional-paged)
@media (overflow-block: paged)
@media (overflow-block: scroll)

How does the device handle overflows along the block axis? MDN

@media (overflow-inline) /* unsupported */
@media (overflow-inline: none)
@media (overflow-inline: scroll)

Can content overflowing the inline axis be scrolled? MDN

@media (pointer) /* unsupported */
@media (pointer: coarse)
@media (pointer: fine)
@media (pointer: none)

Is the input a pointing device? How accurate is it? MDN

@media (prefers-color-scheme) /* unsupported */
@media (prefers-color-scheme: dark)
@media (prefers-color-scheme: light)

Does the user prefer a light or dark color scheme? MDN

@media (prefers-contrast) /* unsupported */
@media (prefers-contrast: custom)
@media (prefers-contrast: less)
@media (prefers-contrast: no-preference)
@media (prefers-contrast: more)

Did the user change the amount of contrast between adjacent colors? MDN

@media (prefers-reduced-data) /* unsupported */
@media (prefers-reduced-data: no-preference)
@media (prefers-reduced-data: reduce)

Has the user requested web content that consumes less bandwidth? MDN

@media (prefers-reduced-motion) /* unsupported */
@media (prefers-reduced-motion: no-preference)
@media (prefers-reduced-motion: reduce)

Does the user prefer less motion? MDN

@media (prefers-reduced-transparency) /* unsupported */
@media (prefers-reduced-transparency: no-preference)
@media (prefers-reduced-transparency: reduce)

Does the user want less transparency or translucent layer effects? MDN

@media (resolution) JavaScript Required
@media (resolution) JavaScript Required
@media (resolution) JavaScript Required

Output pixel density. MDN

@media (scan) /* unsupported */
@media (scan: interlace)
@media (scan: progressive)

Is the display progressive or interlaced? MDN

@media (scripting) /* unsupported */
@media (scripting: enabled)
@media (scripting: initial-only)
@media (scripting: none)

Is JavaScript enabled? MDN

@media (shape) /* unsupported */
@media (shape: rect)
@media (shape: round)

Distinguish regular and round displays. MDN

@media (update) /* unsupported */
@media (update: none)
@media (update: slow)
@media (update: fast)

How frequently can the device modify the appearance of content. MDN

@media (video-dynamic-range) /* unsupported */
@media (video-dynamic-range: high)
@media (video-dynamic-range: standard)

Combination of brightness, contrast ratio, and color depth supported by video. MDN

@media (width) JavaScript Required
@media (width) JavaScript Required

Width of the viewport, including scrollbar. MDN