MDN self-hosted library · e01.org

Using media queries

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

css
@media print {
  /* … */
}
css
@media screen, print {
  /* … */
}
css
@media (hover: hover) {
  /* … */
}
css
@media print and (orientation: portrait) {
  /* … */
}
css
@media (max-width: 1250px) {
  /* … */
}
css
@media (width <= 1250px) {
  /* … */
}

@media (1250px >= width) {
  /* … */
}
css
@media (min-width: 30em) and (max-width: 50em) {
  /* … */
}

@media (30em <= width <= 50em) {
  /* … */
}

@media (50em >= width >= 30em) {
  /* … */
}
css
@media (30em < width < 50em) {
  /* … */
}

@media (50em > width > 30em) {
  /* … */
}
css
@media (color) {
  /* … */
}
css
@media (width >= 30em) and (orientation: landscape) {
  /* … */
}
css
@media screen and (width >= 30em) and (orientation: landscape) {
  /* … */
}
css
@media (height >= 680px), screen and (orientation: portrait) {
  /* … */
}
css
@media not print {
  /* … */
}
css
@media not screen and (color), print and (color) {
  /* … */
}
css
@media not ((width > 1000px) and (color)), print and (color) {
  /* … */
}
css
@media (not (width > 1000px)) and (color), print and (color) {
  /* … */
}
css
@media screen and not (hover) {
  /* … */
}
css
@media only screen and (color) {
  /* … */
}
css
@media (not (color)) or (hover) {
  /* … */
}
css
@media ((color) and (hover)) or (monochrome) {
  /* … */
}

/* or */
@media (color) and (hover), (monochrome) {
  /* … */
}