CSS Media Query Quick Reference

Introduction

Using media queries

There are three ways to include media queries:

Media types

The media types defined in CSS2 are:

Logical operators

Multiple media types can be combined to several types of display devices. Additional display features can also be included to specify the minimum requirement of the media type, etc.

Media feature

The syntax to use a media feature is (name: value).The following media features can be used in media queries:

Media featureMeaningValue
width/max-width/min-widthThe width of the targeted display area of the output deviceA length value. Eg., @media screen and (width: 480px)
height/max-height/min-heightThe height of the targeted display area of the output deviceA length value. Eg., @media screen and (height: 20em)
devide-width/max-devide-width/min-devide-widthThe width of the rendering surface of the output deviceA length value
devide-height/max-devide-height/min-devide-heightThe height of the rendering surface of the output deviceA length value
aspect-ratio/max-aspect-ratio/min-aspect-ratioThe ratio of the value of "width" feature to that of "height" featureTwo integers separated by /. Eg., @media screen and (aspect-ratio: 4/3)
device-aspect-ratio/max-device-aspect-ratio/min-device-aspect-ratioThe ratio of the value of "device-width" feature to that of "device-height" featureTwo integers separated by /. Eg., @media screen and (device-aspect-ratio: 16/9)
color/max-color/min-colorThe number of bits per color component of the output device. If the device is not a color device, the value is 0.Eg., @media all and (color)
color-index/max-color-index/min-color-indexThe number of entries in the color lookup table of the output device. If the device is not a color device, the value is 0.Eg., @media all and (min-color-index: 256)
monochrome/max-monochrome/min-monochromeThe number of bits per pixel in a monochrome frame buffer. If the device is not a monochrome device, the value is 0.Eg., @media all and (min-monochrome: 1)
resolution/max-resolution/min-resolutionThe density of pixels of the output device. resolution matches square pixels. max-resolution and min-resolution can match non-square pixels.An integer with unit of dpi or dpcm. Eg., @media print and (min-resolution: 300dpi)
orientationThe orientation of the output deviceportrait or landscape
scanThe scanning process of TV output device.progressive or interlace

References

  1. Media Queries
  2. CSS media queries
  3. Jason C. Teague, CSS3: Visual QuickStart Guide, 5th edition
  4. Peter Gasston, The Book of CSS3: A Developer's Guide to the Future of Web Design