1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<HEAD>
<TITLE>Media types</TITLE>
<link rel="stylesheet" href="style/default.css" type="text/css">
<link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/W3C-CR.css" type="text/css">
<link rel="prev" href="cascade.html">
<link rel="next" href="box.html">
<link rel="contents" href="cover.html#minitoc">
<link rel="CSS-properties" href="propidx.html" title="properties">
<link rel="index" href="indexlist.html" title="index">
<link rel="first" href="cover.html">
</HEAD>
<BODY>
<div class="navbar">
<p><a href="cascade.html">previous</a>
<a href="box.html">next</a>
<a href="cover.html#minitoc">contents</a>
<a href="propidx.html">properties</a>
<a href="indexlist.html">index</a>
</div>
<hr class="navbar">
<H1><a name="q0">7 Media types</a></H1>
<div class="subtoc">
<p><strong>Contents</strong>
<ul class="toc">
<li class="tocline2"><a href="media.html#media-intro" class="tocxref">7.1 Introduction to media types</a>
<li class="tocline2"><a href="media.html#media-sheets" class="tocxref">7.2 Specifying media-dependent style sheets</a>
<ul class="toc">
<li class="tocline3"><a href="media.html#at-media-rule" class="tocxref">7.2.1 The @media rule</a>
</ul>
<li class="tocline2"><a href="media.html#media-types" class="tocxref">7.3 Recognized media types</a>
<ul class="toc">
<li class="tocline3"><a href="media.html#media-groups" class="tocxref">7.3.1 Media groups</a>
</ul>
</ul>
</div>
<H2>7.1 <a name="media-intro">Introduction to media types</a></H2>
<P>One of the most important features of style sheets is that they
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.
<P>Certain CSS properties are only designed for certain media (e.g.,
the <a href="page.html#propdef-page-break-before" class="noxref"><span
class="propinst-page-break-before">'page-break-before'</span></a> property
only applies to paged media). On occasion, however, style sheets for
different media types may share a property, but require different
values for that property. For example, the <a href="fonts.html#propdef-font-size" class="noxref"><span
class="propinst-font-size">'font-size'</span></a> property is useful both
for screen and print media. The two media types 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.
Therefore, it is necessary to express that a style sheet, or a
section of a style sheet, applies to certain media types.
<H2>7.2 <a name="media-sheets">Specifying media-dependent style sheets</a></H2>
<P>There are currently two ways to specify media dependencies for
style sheets:</p>
<UL>
<LI>Specify the target medium from a style sheet with the <a name="x0"><span
class="index-inst" title="@media">@media</span></a> or <a name="x1"><span
class="index-inst" title="@import">@import</span></a> at-rules.
<div class="example"><P style="display:none">Example(s):</P>
<PRE>
@import url("fancyfonts.css") screen;
@media print {
/* style sheet for print goes here */
}
</PRE>
</div>
<LI>Specify the target medium within the document language. For
example, in HTML 4 (<a href="refs.html#ref-HTML4" rel="biblioentry" class="noxref"><span class="informref">[HTML4]</span></a>), the "media" attribute on the LINK
element specifies the target media of an external style sheet:
<div class="html-example">
<PRE>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
<HEAD>
<TITLE>Link to a target medium</TITLE>
<LINK REL="stylesheet" TYPE="text/css"
MEDIA="print, handheld" HREF="foo.css">
</HEAD>
<BODY>
<P>The body...
</BODY>
</HTML>
</PRE>
</div>
</UL>
<p>The <a href="cascade.html#at-import">@import</a> rule is defined in
the <a href="cascade.html">chapter on the cascade</a>.
<H3>7.2.1 <a name="at-media-rule">The @media rule</a></H3>
<P>An <a name="x2"><span class="index-def" title="media">@media</span></a> rule
specifies the target <a href="media.html#media-types">media types</a> (separated
by commas) of a set of <a
href="syndata.html#tokenization">statements</a> (delimited by curly
braces). Invalid statements must be ignored per <a
href="syndata.html#rule-sets">4.1.7 "Rule sets, declaration blocks,
and selectors"</a> and <a href="syndata.html#parsing-errors">4.2
"Rules for handling parsing errors."</a> The <a name="x3"><span
class="index-inst" title="@media">@media</span></a> construct allows style
sheet rules for various media in the same style sheet:</P>
<pre class="example">
@media print {
body { font-size: 10pt }
}
@media screen {
body { font-size: 13px }
}
@media screen, print {
body { line-height: 1.2 }
}
</pre>
<p>Style rules outside of @media rules apply to all media types
that the style sheet applies to. At-rules inside @media are invalid in
CSS2.1.
<H2>7.3 <a name="media-types">Recognized media types</a></H2>
<P>The names chosen for CSS media types reflect target devices for
which the relevant properties make sense. In the following list of CSS
media types the names of media types are normative, but the
descriptions are informative. Likewise, the "Media" field in the
description of each property is informative.
<dl>
<dt><strong>all</strong>
<dd>Suitable for all devices.
<dt><strong>braille</strong>
<dd>Intended for braille tactile feedback devices.
<dt><strong>embossed</strong>
<dd>Intended for paged braille printers.
<dt><strong>handheld</strong>
<dd>Intended for handheld devices (typically small
screen, limited bandwidth).
<dt><strong>print</strong>
<dd>Intended for paged material and for documents viewed on
screen in print preview mode. Please consult the section on <a
href="page.html">paged media</a> for information about formatting
issues that are specific to paged media.
<dt><strong>projection</strong>
<dd>Intended for projected presentations, for example projectors.
Please consult the section on <a href="page.html">paged media</a> for
information about formatting issues that are specific to paged media.
<dt><strong>screen</strong>
<dd>Intended primarily for color computer screens.
<dt><strong>speech</strong>
<dd>Intended for speech synthesizers. Note: CSS2 had a similar media type
called 'aural' for this purpose. See the appendix on
<a href="aural.html">aural style sheets</a> for details.
<dt><strong>tty</strong>
<dd>Intended for media using a fixed-pitch character grid (such as
teletypes, terminals, or portable devices with limited display
capabilities). Authors should not use <a
href="syndata.html#pixel-units">pixel units</a> with the "tty" media
type.
<dt><strong>tv</strong>
<dd>Intended for television-type devices (low
resolution, color, limited-scrollability screens, sound available).
</dl>
<P>Media type names are case-insensitive.
<P>Media types are mutually exclusive in the sense that a user agent can
only support one media type when rendering a document. However, user
agents may use different media types on different canvases. For
example, a document may (simultaneously) be shown in 'screen' mode on
one canvas and 'print' mode on another canvas.
<p>Note that a multimodal media type is still only one media
type. The 'tv' media type, for example, is a multimodal media
type that renders both visually and aurally to a single canvas.
<p>@media and @import rules with unknown media types are treated as if
the unknown media types are not present.
<div class="example"><P style="display:none">Example(s):</P>
<p>For example, in the following snippet, the rule on the P element applies
in 'screen' mode (even though the '3D' media type is not known).
<pre>
@media screen, 3D {
P { color: green; }
}
</pre>
</div>
<div class="note"><P>
<em><strong>Note.</strong>
Future updates of CSS may extend the list of media types. Authors
should not rely on media type names that are not yet defined
by a CSS specification.
</em>
</div>
<H3>7.3.1 <a name="media-groups">Media groups</a></H3>
<P><em>This section is informative, not normative.</em></P>
<P>Each CSS property definition specifies which media types the
property applies to. Since properties generally apply to several media
types, the "Applies to media" section of each property definition
lists <a name="x4"><span class="index-def" title="media group">media groups</span></a>
rather than individual media types. Each property applies to all media
types in the media groups listed in its definition.
<P>CSS 2.1 defines the following media groups: </P>
<ul>
<li>
<span class="index-def" title="'continuous' media group"><a
name="continuous-media-group"><strong>continuous</strong></a></span>
or <span class="index-def" title="'paged' media group"><a
name="paged-media-group"><strong>paged</strong></a></span>.
<li><span
class="index-def" title="'visual' media group"><a
name="visual-media-group"> <strong>visual</strong></a>,</span>
<span class="index-def" title="'audio' media group"><a
name="audio-media-group"><strong>audio</strong></a>,</span>
<span class="index-def" title="'speech' media group"><a
name="speech-media-group"><strong>speech</strong></a>,</span>
or <span
class="index-def" title="'tactile' media group"><a
name="tactile-media-group"><strong>tactile</strong></a></span>.
<li><span
class="index-def" title="'grid' media group"><a
name="grid-media-group"><strong>grid</strong></a></span> (for
character grid devices), or
<span
class="index-def" title="'bitmap' media group"><a
name="bitmap-media-group"><strong>bitmap</strong></a></span>.
<li><span
class="index-def" title="'interactive media group"><a
name="interactive-media-group"><strong>interactive</strong></a></span> (for
devices that allow user interaction), or
<span
class="index-def" title="'static' media group"><a
name="static-media-group"><strong>static</strong></a></span> (for
those that don't).
<li><span class="index-def" title="'all'
media group"> <a name="all-media-group"><strong>all</strong></a></span>
(includes all media types)
</ul>
<P>The following table shows the relationships
between media groups and media types:</P>
<TABLE border=1
summary="Relationship between media groups and media types">
<CAPTION>Relationship between media groups and media types</CAPTION>
<TR><TH>Media Types <TH colspan="4">Media Groups
<TR><TH>
<TH>continuous/paged
<TH>visual/audio/speech/tactile
<TH>grid/bitmap
<TH>interactive/static
<TR><TH>braille<TD align="center">continuous<TD align="center">tactile<TD align="center">grid<TD align="center">both</TR>
<TR><TH>embossed<TD align="center">paged<TD align="center">tactile<TD align="center">grid<TD align="center">static</TR>
<TR><TH>handheld<TD align="center">both<TD align="center">visual, audio, speech<TD
align="center">both<TD align="center">both</TR>
<TR><TH>print<TD align="center">paged<TD align="center">visual<TD
align="center">bitmap<TD align="center">static</TR>
<TR><TH>projection<TD align="center">paged<TD align="center">visual<TD align="center">bitmap<TD align="center">interactive</TR>
<TR><TH>screen<TD align="center">continuous<TD align="center">visual, audio<TD align="center">bitmap<TD align="center">both</TR>
<TR><TH>speech<TD align="center">continuous<TD align="center">speech<TD align="center">N/A<TD align="center">both</TR>
<TR><TH>tty<TD align="center">continuous<TD align="center">visual<TD align="center">grid<TD align="center">both</TR>
<TR><TH>tv<TD align="center">both<TD align="center">visual, audio<TD align="center">bitmap<TD align="center">both</TR>
</TABLE>
<hr class="navbar">
<div class="navbar">
<p><a href="cascade.html">previous</a>
<a href="box.html">next</a>
<a href="cover.html#minitoc">contents</a>
<a href="propidx.html">properties</a>
<a href="indexlist.html">index</a>
</div>
</BODY>
</html>
|