Movatterモバイル変換


[0]ホーム

URL:


previous  next  contents  properties  index  


7 Media types

Contents

Note: Several sections of this specification have been updated by other specifications. Please, see"Cascading Style Sheets (CSS) — The Official Definition" in the latestCSS Snapshot for a list of specifications and the sections they replace.

The CSS Working Group is also developingCSS level 2 revision 2 (CSS 2.2).

7.1Introduction to media types

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

Certain CSS properties are only designed for certain media (e.g.,the'page-break-before' propertyonly applies to paged media). On occasion, however, style sheets fordifferent media types may share a property, but require differentvalues for that property. For example, the'font-size' property is useful bothfor screen and print media. The two media types are different enoughto require different values for the common property; a document willtypically need a larger font on a computer screen than on paper.Therefore, it is necessary to express that a style sheet, or asection of a style sheet, applies to certain media types.

7.2Specifying media-dependent style sheets

There are currently two ways to specify media dependencies forstyle sheets:

The@import rule is defined inthechapter on the cascade.

7.2.1The @media rule

An@media rulespecifies the targetmedia types (separatedby commas) of a set ofstatements (delimited by curlybraces). Invalid statements must be ignored per4.1.7 "Rule sets, declaration blocks,and selectors" and4.2"Rules for handling parsing errors." The@media construct allows stylesheet rules for various media in the same style sheet:

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

Style rules outside of @media rules apply to all media typesthat the style sheet applies to. At-rules inside @media are invalid inCSS2.1.

7.3Recognized media types

The names chosen for CSS media types reflect target devices forwhich the relevant properties make sense. In the following list of CSSmedia types the names of media types are normative, but thedescriptions are informative. Likewise, the "Media" field in the description of each property is informative.

all
Suitable for all devices.
braille
Intended for braille tactile feedback devices.
embossed
Intended for paged braille printers.
handheld
Intended for handheld devices (typically smallscreen, limited bandwidth).
print
Intended for paged material and for documents viewed onscreen in print preview mode. Please consult the section onpaged media for information about formattingissues that are specific to paged media.
projection
Intended for projected presentations, for example projectors.Please consult the section onpaged media forinformation 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 onaural style sheets for details.
tty
Intended for media using a fixed-pitch character grid (such asteletypes, terminals, or portable devices with limited displaycapabilities). Authors should not usepixel units with the "tty" mediatype.
tv
Intended for television-type devices (low resolution, color, limited-scrollability screens, sound available).

Media type names are case-insensitive.

Media types are mutually exclusive in the sense that a user agent canonly support one media type when rendering a document. However, useragents may use different media types on different canvases. Forexample, a document may (simultaneously) be shown in 'screen' mode onone canvas and 'print' mode on another canvas.

Note that a multimodal media type is still only one mediatype. The 'tv' media type, for example, is a multimodal mediatype that renders both visually and aurally to a single canvas.

@media and @import rules with unknown media types (that arenonetheless valid identifiers) are treated as if the unknown mediatypes are not present. If an @media/@import rule contains a malformedmedia type (not an identifier) then the statement is invalid.

Note: Media Queries supercedes thiserror handling.

Example(s):

For example, in the following snippet, the rule on the P element appliesin 'screen' mode (even though the '3D' media type is not known).

@media screen, 3D {  P { color: green; }}

Note.Future updates of CSS may extend the list of media types. Authorsshould not rely on media type names that are not yet definedby a CSS specification.

7.3.1Media groups

This section is informative, not normative.

Each CSS property definition specifies which media types theproperty applies to. Since properties generally apply to several mediatypes, the "Applies to media" section of each property definitionlistsmedia groupsrather than individual media types. Each property applies to all mediatypes in the media groups listed in its definition.

CSS 2.1 defines the following media groups:

The following table shows the relationshipsbetween media groups and media types:

Relationship between media groups and media types
Media TypesMedia Groups
 continuous/pagedvisual/audio/speech/tactilegrid/bitmapinteractive/static
braillecontinuoustactilegridboth
embossedpagedtactilegridstatic
handheldbothvisual, audio, speechbothboth
printpagedvisualbitmapstatic
projectionpagedvisualbitmapinteractive
screencontinuousvisual, audiobitmapboth
speechcontinuousspeechN/Aboth
ttycontinuousvisualgridboth
tvbothvisual, audiobitmapboth

previous  next  contents  properties  index  


[8]ページ先頭

©2009-2025 Movatter.jp