7 Media types


  1. Introduction to media types
  2. Specifying media-dependent style sheets
    1. The @media rule
    2. The media-dependent @import rule
  3. Recognized media types
    1. Media groups

7.1 Introduction to media types

One of the most important features of style sheets is that they allow authors to specify how a document is to be presented on different media: on the screen, on paper, with a speech synthesizer, with a braille device, etc.

Certain CSS properties are only designed for certain media (e.g., the 'cue-before' property for aural style sheets). On occasion, however, style sheets for different media types may share a property, but require different values for that property. For example, the 'font-size' property is useful both for screen and print media. However, the two media are different enough to require different values for the common property; a document will typically need a larger font on a computer screen than on paper. Experience also shows that sans serif fonts are easier to read on screen, while fonts with serifs are easier to read on paper. For these reasons, it is necessary to express that a style sheet -- or a section of a style sheet -- applies to certain media types.

Below we describe how authors may specify different style sheets for different media (all of which participate in the cascade).

7.2 Specifying media-dependent style sheets

There are currently two ways to specify media dependencies for style sheets:

Since these two examples specify the same media type, they are semantically equivalent.

7.2.1 The @media rule

An @media rule lists the media types (separated by commas) affected by a set of rules delimited by curly braces.

The @media construct allows style sheet rules for various media in the same style sheet:

  @media print {
    BODY { font-size: 10pt }
  @media screen {
    BODY { font-size: 12pt }
  @media screen, print {
    BODY { line-height: 1.2 }

7.2.2 The media-dependent @import rule

So that user agents can avoid retrieving resources for unsupported media types, authors may specify media-dependent @import rules. These conditional imports specify comma-separated media types after the URI.

The following rules have the same effect as if the imported style sheet were wrapped in an @media rule for the same media, but it may save the UA a fruitless download.

@import url(fineprint.css) print;
@import url(bluish.css) projection, tv;

In the absence of any media types, the import is unconditional. Specifying 'all' for the medium has the same effect.

7.3 Recognized media types

Due to rapidly changing technologies, CSS2 does not specify a definitive list of media types that may be values for @media. However, user agents that elect to support the devices in the following list must recognize the associated media type:

Suitable for all devices.
Intended for speech synthesizers. See the section on aural style sheets for details.
Intended for braille tactile feedback devices.
Intended for paged braille printers.
Intended for handheld devices (small screen, monochrome, limited bandwidth).
Intended for paged, opaque material and for documents viewed on screen in print preview mode. Please consult the section on paged media for information about formatting issues that are specific to paged media.
Intended for projected presentations, for example projectors or print to transparencies. Please consult the section on paged media for information about formatting issues that are specific to paged media.
Intended primarily for color computer screens. See the section on rendering to continuous media for more information.
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.
Intended for television-type devices (low resolution, color, limited scrollability).

Media type names are case-insensitive.

7.3.1 Media groups

Each CSS property definition specifies the media types for which the property must be implemented by a conforming user agent. Since properties generally apply to several media, the "Applies to media" section of each property definition indicates a media group rather than a list of media types. A property applies to all media types that belong to a given media group.

CSS2 defines the following media groups:

The following table shows the relationships between media groups and media types:

Media Groups
Media Groups
Media Types
continuous/paged visual/aural/tactile character grid
handheld visual 
tv visual, aural