CSS
Media queries

Media queries

Media Types

  1. all
  2. print
  3. screen
  4. speech

Media Features

prefers-color-scheme

To detect if the user has requested the system use a light or dark color theme.

@media (prefers-color-scheme: dark) {
  .dark-scheme {
    background: #222;
    color: white;
  }
}
 
@media (prefers-color-scheme: light) {
  .light-scheme {
    background: white;
    color: black;
  }
}

See also

prefers-reduced-motion

To detect if the user has requested that the system minimize the amount of non-essential motion it uses.

@media (prefers-reduced-motion: reduce) {
  /*  ...  */
}

See also

References

  1. @media - CSS: Cascading Style Sheets | MDN (opens in a new tab)
  2. Using media queries - CSS: Cascading Style Sheets | MDN (opens in a new tab)
  3. Media Queries Level 5 | w3.org (opens in a new tab)