media property CSS Reference



Definition and Usage

The @media CSS at-rule< associates a set of nested statements, in a CSS block, that is delimited by curly braces, with a condition defined by a media query. The @media at-rule may be used not only at the top level of a CSS, but also inside any CSS conditional-group at-rule.

The @media at-rule can be accessed via the CSS object model interface CSSMediaRule.


Syntax

@media <media types> {
  /* media-specific rules */
}

Media types

all
Suitable for all devices.
braille
Intended for braille tactile feedback devices.
embossed
Intended for paged braille printers.
handheld
Intended for handheld devices (typically small screen, limited bandwidth).
print
Intended for paged material and for documents viewed on screen in print preview mode.
projection
Intended for projected presentations, for example projectors. Please consult the section on paged media for information about formatting issues that are specific to paged media.
screen
Intended primarily for color computer screens.
speech
Intended for speech synthesizers. Note: CSS2 had a similar media type called 'aural' for this purpose. See the appendix on aural style sheets for details.
tty
Intended for media using a fixed-pitch character grid (such as teletypes, terminals, or portable devices with limited display capabilities). Authors should not use pixel units with the "tty" media type.
tv
Intended for television-type devices (low resolution, color, limited-scrollability screens, sound available).

Media groups

Media types are also part of different Media Groups. The following table indicates which types are in which group.

 Groups
Typecontinuouspagedvisualaudiospeechtactilegridbitmapinteractivestatic
brailleX    XX XX
embossed X   XX  X
handheldXXXXX XXXX
print XX    X X
projection XX    XX 
screenX XX   XXX
speechX   X   XX
ttyX X   X XX
tvXXXX   XXX

Examples

@media print {
  body { font-size: 10pt }
}
@media screen {
  body { font-size: 13px }
}
@media screen, print {
  body { line-height: 1.2 }
}

Compatibility

Desktop browsers

FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support1.01.0 (1.7 or earlier)9.09.21.3

Mobile browsers

FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support1.01.0 (1.7)9.09.03.1

Relative articles