mediaqueries/Overview.bs

Sun, 31 Jan 2016 15:42:31 -0800

author
Peter Linss <[email protected]>
date
Sun, 31 Jan 2016 15:42:31 -0800
changeset 16986
5be73fbc8592
parent 16768
e6b3e3493793
child 16989
255258410d1b
permissions
-rw-r--r--

change //dev.w3.org/csswg/ urls to //drafts.csswg.org/

     1 <h1>Media Queries Level 4</h1>
     3 <pre class='metadata'>
     4 Group: csswg
     5 Shortname: mediaqueries
     6 Level: 4
     7 Status: ED
     8 Work Status: Exploring
     9 ED: https://drafts.csswg.org/mediaqueries4/
    10 TR: http://www.w3.org/TR/mediaqueries-4/
    11 Previous Version: http://www.w3.org/TR/2014/WD-mediaqueries-4-20140605/
    12 Editor: Florian Rivoal, Vivliostyle, [email protected], http://www.vivliostyle.com
    13 Editor: Tab Atkins Jr., Google, http://xanthir.com/contact/
    14 Former Editor: HÃ¥kon Wium Lie, Opera, [email protected]
    15 Former Editor: Tantek Çelik, Mozilla, [email protected]
    16 Former Editor: Daniel Glazman, Disruptive Innovations, [email protected]
    17 Former Editor: Anne van Kesteren, Mozilla, [email protected]
    18 Abstract: <a>Media Queries</a> allow authors to test and query values or features of the user agent or display device, independent of the document being rendered.  They are used in the CSS @media rule to conditionally apply styles to a document, and in various other contexts and languages, such as HTML and Javascript.
    19 Abstract:
    20 Abstract: Media Queries Level 4 describes the mechanism and syntax of media queries, media types, and media features. It extends and supersedes the features defined in Media Queries Level 3.
    21 Ignored Terms: min-resolution, max-resolution, none, view-mode, mediaText, DOMString
    22 Link Defaults: css-break-3 (property) break-inside
    23 </pre>
    25 <h2 id="intro">
    26 Introduction</h2>
    28 	<em>This section is not normative.</em>
    30 	HTML4 [[HTML401]] defined a mechanism to support media-dependent style sheets,
    31 	tailored for different <a>media types</a>.
    32 	For example, a document may use different style sheets for screen and for print.
    33 	In HTML, this can be written as:
    35 	<div class="example">
    36 		<pre>
    37 			&lt;link rel="stylesheet" type="text/css" media="screen" href="style.css">
    38 			&lt;link rel="stylesheet" type="text/css" media="print" href="print.css">
    39 		</pre>
    40 	</div>
    42 	CSS adapted and extended this functionality with its ''@media'' and ''@import'' rules,
    43 	adding the ability to query the value of individual features:
    45 	<div class="example">
    46 		Inside a CSS style sheet,
    47 		one can declare that sections apply to certain <a>media types</a>:
    49 		<pre>
    50 			@media screen {
    51 				* { font-family: sans-serif }
    52 			}
    53 		</pre>
    55 		Similarly, stylesheets can be conditionally imported based on media queries:
    57 		<pre>@import "print-styles.css" print;</pre>
    58 	</div>
    60 	<a>Media queries</a> can be used with HTML, XHTML, XML [[XMLSTYLE]] and the @import and @media rules of CSS.
    62 	<div class="example">
    63 		Here is the same example written in HTML, XHTML, XML, @import and @media:
    65 		<pre>
    66 			&lt;link media="screen and (color), projection and (color)"
    67 			      rel="stylesheet" href="example.css">
    69 			&lt;link media="screen and (color), projection and (color)"
    70 			      rel="stylesheet" href="example.css" />
    72 			&lt;?xml-stylesheet media="screen and (color), projection and (color)"
    73 			                 rel="stylesheet" href="example.css" ?>
    75 			@import url(example.css) screen and (color), projection and (color);
    77 			@media screen and (color), projection and (color) { … }
    78 		</pre>
    80 		Note: The [[XMLSTYLE]] specification has not yet been updated to
    81 		use media queries in the <code>media</code> pseudo-attribute.
    82 	</div>
    84 <h3 id="placement">
    85 Module interactions</h3>
    87 	This module replaces and extends the Media Queries, Media Type and Media Features
    88 	defined in [[!CSS21]] sections 7 and in [[!MEDIAQ]].
    90 <h3 id="values">
    91 Values</h3>
    93 	Value types not defined in this specification, such as <<integer>>,
    94 	<<number>> or <<resolution>>, are defined in [[!CSS3VAL]].  Other CSS
    95 	modules may expand the definitions of these value types.
    97 	This specification also introduces some new value types.
    99 	The <dfn type>&lt;ratio></dfn> value type is a positive (not zero or negative)
   100 	<<integer>> followed by optional whitespace, followed by a solidus ('/'),
   101 	followed by optional whitespace, followed by a positive <<integer>>.
   102 	<<ratio>>s can be ordered or compared by transforming them into the number
   103 	obtained by dividing their first <<integer>> by their second <<integer>>.
   105 	The <dfn type>&lt;mq-boolean></dfn> value type is an <<integer>>
   106 	with the value ''0'' or ''1''.
   107 	Any other integer value is invalid.
   108 	<span class='note'>Note that ''-0'' is always equivalent to ''0'' in CSS,
   109 	and so is also accepted as a valid <<mq-boolean>> value.</span>
   111 <h3 id="units">
   112 Units</h3>
   114 	The units used in media queries are the same as in other parts of CSS, as
   115 	defined in [[!CSS3VAL]]. For example, the pixel unit represents CSS pixels and
   116 	not physical pixels.
   118 	Relative units in media queries are based on the initial value, which means
   119 	that units are never based on results of declarations. For example, in HTML,
   120 	the ''em'' unit is relative to the initial value of 'font-size',
   121 	defined by the user agent or the user's preferences,
   122 	not any styling on the page.
   124 <!--
   125 ██     ██  ███████
   126 ███   ███ ██     ██
   127 ████ ████ ██     ██
   128 ██ ███ ██ ██     ██
   129 ██     ██ ██  ██ ██
   130 ██     ██ ██    ██
   131 ██     ██  █████ ██
   132 -->
   135 <h2 id="media">
   136 Media Queries</h2>
   138 	A <dfn export>media query</dfn> is a method of testing certain aspects of the user agent
   139 	or device that the document is being displayed in.
   140 	<a>Media queries</a> are (almost) always independent of the contents of the document,
   141 	its styling,
   142 	or any other internal aspect;
   143 	they're only dependent on “external” information
   144 	unless another feature explicitly specifies that it affects the resolution of Media Queries,
   145 	such as the ''@viewport'' rule.
   147 	The syntax of a <a>media query</a> consists of
   148 	an optional <a>media query modifier</a>,
   149 	an optional <a>media type</a>,
   150 	and zero or more <a>media features</a>:
   152 	<pre class='railroad'>
   153 	Or:
   154 		N: media condition
   155 		And:
   156 			Or: 1
   157 				T: only
   158 				S:
   159 				T: not
   160 			N: media type
   161 			Opt:
   162 				And:
   163 					T: and
   164 					N: media condition
   165 	</pre>
   167 	A <a>media query</a> is a logical expression that is either true or false.
   168 	A media query is true if:
   170 	* the <a>media type</a>,
   171 		if specified,
   172 		matches the media type of the device where the user agent is running, and
   173 	* the <a>media condition</a> is true.
   175 	Statements regarding media queries in this section assume the <a href="#mq-syntax">syntax section</a> is followed.
   176 	Media queries that do not conform to the syntax are discussed in [[#error-handling]].
   177 	I.e. the syntax takes precedence over requirements in this section.
   179 	<div class="example">
   180 		Here is a simple example written in HTML:
   182 		<pre>&lt;link rel="stylesheet" media="screen and (color)" href="example.css" /></pre>
   184 		This example expresses that a certain style sheet
   185 		(<code>example.css</code>) applies to devices of a certain media type
   186 		(''screen'') with certain feature (it must be a color screen).
   188 		Here is the same media query written in an @import-rule in CSS:
   190 		<pre>@import url(example.css) screen and (color);</pre>
   191 	</div>
   193 	User agents must re-evaluate <a>media queries</a> in response to changes in the user environment that they're aware of,
   194 	for example if the device is tiled from landscape to portrait orientation,
   195 	and change the behavior of any constructs dependent on those <a>media queries</a> accordingly.
   197 	Unless another feature explicitly specifies that it affects the resolution of Media Queries, it is never necessary to apply a style sheet in order to evaluate expressions.
   199 	Note: CSS Device Adaptation [[CSS-DEVICE-ADAPT]]]
   200 	defines how ''@viewport'' rules interact with Media Queries.
   202 <h3 id='mq-list'>
   203 Combining Media Queries</h3>
   205 	Several <a>media queries</a> can be combined into a comma-separated <dfn export>media query list</dfn>.
   207 	<pre class='railroad'>
   208 	Star:
   209 		N: media query
   210 		T: ,
   211 	</pre>
   213 	A <a>media query list</a> is true if <em>any</em> of its component <a>media queries</a> are true,
   214 	and false only if <em>all</em> of its component <a>media queries</a> are false.
   216 	<div class="example">
   217 		For example, the following <a>media query list</a> is true if either
   218 		the <a>media type</a> is ''screen'' and it's a color device,
   219 		<strong>or</strong> the <a>media type</a> is ''projection'' and it's a color device:
   221 		<pre>
   222 		@media screen and (color), projection and (color) { … }
   223 		</pre>
   224 	</div>
   226 	An empty <a>media query list</a> evaluates to true.
   228 	<div class="example">
   229 		For example, these are equivalent:
   231 		<pre>
   232 		@media all { … }
   233 		@media { … }
   234 		</pre>
   235 	</div>
   237 <h3 id='mq-prefix'>
   238 Media Query Modifiers</h3>
   240 	A <a>media query</a> may optionally be prefixed by a single <dfn export>media query modifier</dfn>,
   241 	which is a single keyword which alters the meaning of the following <a>media query</a>.
   243 <h4 id='mq-not'>
   244 Negating a Media Query: the ''not'' keyword</h4>
   246 	An individual <a>media query</a> can have its result negated
   247 	by prefixing it with the keyword <dfn value for="@media">not</dfn>.
   248 	If the <a>media query</a> would normally evaluate to true,
   249 	prefixing it with ''not'' makes it evaluate to false,
   250 	and vice versa.
   252 	<div class="example">
   253 		For example, the following will apply to everything except color-capable screens.
   254 		Note that the entire media query is negated,
   255 		not just the <a>media type</a>.
   257 		<pre>&lt;link rel="stylesheet" media="not screen and (color)" href="example.css" /></pre>
   258 	</div>
   260 <h4 id='mq-only'>
   261 Hiding a Media Query From Legacy User Agents: the ''only'' keyword</h4>
   263 	The concept of <a>media queries</a> originates from HTML4 [[HTML401]].
   264 	That specification only defined <a>media types</a>,
   265 	but had a forward-compatible syntax that accommodated the addition of future concepts like <a>media features</a>:
   266 	it would consume the characters of a <a>media query</a> up to the first non-alphanumeric character,
   267 	and interpret that as a <a>media type</a>,
   268 	ignoring the rest.
   269 	For example, the <a>media query</a> ''screen and (color)''
   270 	would be truncated to just ''screen''.
   272 	Unfortunately, this means that legacy user agents using this error-handling behavior
   273 	will ignore any <a>media features</a> in a <a>media query</a>,
   274 	even if they're far more important than the <a>media type</a> in the query.
   275 	This can result in styles accidentally being applied in inappropriate situations.
   277 	To hide these <a>media queries</a> from legacy user agents,
   278 	the <a>media query</a> can be prefixed with the keyword <dfn value for="@media">only</dfn>.
   279 	The ''only'' keyword <strong>has no effect</strong> on the <a>media query</a>’s result,
   280 	but will cause the <a>media query</a> to be parsed by legacy user agents
   281 	as specifying the unknown <a>media type</a> “only”,
   282 	and thus be ignored.
   284 	<div class="example">
   285 		In this example, the stylesheet specified by the <code>&lt;link></code> element
   286 		will not be used by legacy user agents,
   287 		even if they would normally match the ''screen'' <a>media type</a>.
   289 		<pre>&lt;link rel="stylesheet" media="only screen and (color)" href="example.css" /></pre>
   290 	</div>
   292 	Note: Note that the ''only'' keyword can only be used before a <a>media type</a>.
   293 	A <a>media query</a> consisting only of <a>media features</a>,
   294 	or one with another <a>media query modifier</a> like ''not'',
   295 	will be treated as false by legacy user agents automatically.
   297 	Note: At the time of publishing this specification,
   298 	such legacy user agents are extremely rare,
   299 	and so using the ''only'' modifier is rarely, if ever, necessary.
   301 <!--
   302 ████████ ██    ██ ████████  ████████  ██████
   303    ██     ██  ██  ██     ██ ██       ██    ██
   304    ██      ████   ██     ██ ██       ██
   305    ██       ██    ████████  ██████    ██████
   306    ██       ██    ██        ██             ██
   307    ██       ██    ██        ██       ██    ██
   308    ██       ██    ██        ████████  ██████
   309 -->
   311 <h3 id='media-types'>
   312 Media Types</h3>
   314 	A <dfn export>media type</dfn> is a broad category of user-agent devices
   315 	on which a document may be displayed.
   316 	The original set of <a>media types</a> were defined in HTML4,
   317 	for the <code>media</code> attribute on <code>&lt;link></code> elements.
   319 	Unfortunately, <a>media types</a> have proven insufficient as a way of discriminating between devices with different styling needs.
   320 	Some categories which were originally quite distinct,
   321 	such as ''screen'' and ''handheld'',
   322 	have blended significantly in the years since their invention.
   323 	Others, such as ''tty'' or ''tv'',
   324 	expose useful differences from the norm of a full-featured computer monitor,
   325 	and so are potentially useful to target with different styling,
   326 	but the definition of <a>media types</a> as mutually exclusive
   327 	makes it difficult to use them in a reasonable manner;
   328 	instead, their exclusive aspects are better expressed as <a>media features</a>
   329 	such as 'grid' or 'scan'.
   331 	As such, the following <a>media types</a> are defined for use in <a>media queries</a>:
   333 	<dl dfn-type=value dfn-for="@media">
   334 		<dt><dfn>all</dfn>
   335 		<dd>Matches all devices.
   337 		<dt><dfn>print</dfn>
   338 		<dd>Matches printers, and devices intended to reproduce a printed display,
   339 			such as a web browser showing a document in “Print Preview”.
   341 		<dt><dfn>screen</dfn>
   342 		<dd>Matches all devices that aren't matched by ''print'' or ''speech''.
   344 		<dt><dfn>speech</dfn>
   345 		<dd>Matches screenreaders and similar devices that “read out” a page.
   346 	</dl>
   348 	In addition, the following <strong>deprecated</strong> <a>media types</a> are defined.
   349 	Authors must not use these <a>media types</a>;
   350 	instead, it is recommended that they select appropriate <a>media features</a>
   351 	that better represent the aspect of the device that they are attempting to style against.
   353 	User agents must recognize the following <a>media types</a> as valid,
   354 	but must make them match nothing.
   356 	<ul dfn-type=value dfn-for="@media">
   357 		<li><dfn>tty</dfn>
   358 		<li><dfn>tv</dfn>
   359 		<li><dfn>projection</dfn>
   360 		<li><dfn>handheld</dfn>
   361 		<li><dfn>braille</dfn>
   362 		<li><dfn>embossed</dfn>
   363 		<li><dfn>aural</dfn>
   364 	</ul>
   366 	Note: It is expected that all of the media types will also be deprecated in time,
   367 	as appropriate <a>media features</a> are defined which capture their important differences.
   369 <!--
   370 ████████ ████████    ███    ████████ ██     ██ ████████  ████████  ██████
   371 ██       ██         ██ ██      ██    ██     ██ ██     ██ ██       ██    ██
   372 ██       ██        ██   ██     ██    ██     ██ ██     ██ ██       ██
   373 ██████   ██████   ██     ██    ██    ██     ██ ████████  ██████    ██████
   374 ██       ██       █████████    ██    ██     ██ ██   ██   ██             ██
   375 ██       ██       ██     ██    ██    ██     ██ ██    ██  ██       ██    ██
   376 ██       ████████ ██     ██    ██     ███████  ██     ██ ████████  ██████
   377 -->
   379 <h3 id='mq-features'>
   380 Media Features</h3>
   382 	A <dfn export>media feature</dfn> is a more fine-grained test than <a>media types</a>,
   383 	testing a single, specific feature of the user agent or display device.
   385 	Syntactically, <a>media features</a> resemble CSS properties:
   386 	they consist of a feature name, a colon, and a value to test for.
   387 	They may also be written in boolean form as just a feature name,
   388 	or in range form with a comparison operator.
   390 	<pre class='railroad'>
   391 	T: (
   392 	Choice:
   393 		And:
   394 			N: feature name
   395 			T: :
   396 			N: feature value
   397 		N: feature name
   398 		And:
   399 			N: range form
   400 			C: (see below)
   401 	T: )
   402 	</pre>
   404 	There are, however, several important differences between properties and media features:
   406 	<ul>
   407 		<li>
   408 			Properties are used to give information about how to present a document.
   409 			Media features are used to describe requirements of the output device.
   411 		<li>
   412 			Media features are always wrapped in parentheses
   413 			and combined with the ''and'' keyword,
   414 			like ''(color) and (min-width: 600px)'',
   415 			rather than being separated with semicolons.
   417 		<li>
   418 			A media feature may be given with <em>only</em> its name
   419 			(omitting the colon and value)
   420 			to evaluate the feature in a <a>boolean context</a>.
   421 			This is a convenient shorthand for features that have a reasonable value representing 0 or “none”.
   422 			For example, ''(color)'' is true is the 'color' <a>media feature</a> is non-zero.
   424 		<li>
   425 			<a>Media features</a> with “range” type can be written in a <a>range context</a>,
   426 			which uses standard mathematical comparison operators rather than a colon,
   427 			or have their feature names <a href=#mq-min-max>prefixed with “min-” or “max-”</a>.
   429 		<li>
   430 			Properties sometimes accept complex values,
   431 			e.g., calculations that involve several other values.
   432 			<a>Media features</a> only accept single values: one keyword, one number, etc.
   433 	</ul>
   435 	If a <a>media feature</a> references a concept which does not exist on the device where the UA is running
   436 	(for example, speech UAs do not have a concept of "width"),
   437 	the <a>media feature</a> must always evaluate to false.
   439 	<div class="example">
   440 		The media feature ''device-aspect-ratio'' only applies to
   441 		visual devices. On an ''speech'' device, expressions involving
   442 		''device-aspect-ratio'' will therefore always be false:
   444 		<pre>
   445 			&lt;link media="speech and (device-aspect-ratio: 16/9)"
   446 			      rel="stylesheet" href="example.css">
   447 		</pre>
   448 	</div>
   450 <h4 id='mq-ranges'>
   451 Media Feature Types: “range” and “discrete”</h4>
   453 	Every media feature defines its “type” as either “range” or “discrete” in its definition table.
   455 	“Discrete” media features,
   456 	like 'light-level' or 'scripting',
   457 	take their values from a set.
   458 	The values may be keywords
   459 	or boolean numbers (0 and 1),
   460 	but the common factor is that there's no intrinsic “order” to them--
   461 	none of the values are “less than” or “greater than” each other.
   463 	“Range” media features like 'width', on the other hand,
   464 	take their values from a range.
   465 	Any two values can be compared to see which is lesser and which is greater.
   467 	The only significant difference between the two types is that “range” <a>media features</a>
   468 	can be evaluated in a <a>range context</a>
   469 	and accept “min-” and “max-” prefixes on their name.
   470 	Doing either of these changes the meaning of the feature--
   471 	rather than the <a>media feature</a> being true when the feature exactly matches the given value,
   472 	it matches when the feature is greater than/less than/equal to the given value.
   474 	<div class='example'>
   475 		A <span class=css data-link-type=maybe>(width >= 600px)</span> <a>media feature</a> is true
   476 		when the viewport's width is ''600px'' <em>or more</em>.
   478 		On the other hand, ''(width: 600px)'' by itself is only true
   479 		when the viewport's width is <em>exactly</em> ''600px''.
   480 		If it's less or greater than ''600px'', it'll be false.
   481 	</div>
   483 <!--
   484 ████████   ███████   ███████  ██       ████████    ███    ██    ██
   485 ██     ██ ██     ██ ██     ██ ██       ██         ██ ██   ███   ██
   486 ██     ██ ██     ██ ██     ██ ██       ██        ██   ██  ████  ██
   487 ████████  ██     ██ ██     ██ ██       ██████   ██     ██ ██ ██ ██
   488 ██     ██ ██     ██ ██     ██ ██       ██       █████████ ██  ████
   489 ██     ██ ██     ██ ██     ██ ██       ██       ██     ██ ██   ███
   490 ████████   ███████   ███████  ████████ ████████ ██     ██ ██    ██
   491 -->
   493 <h4 id='mq-boolean-context'>
   494 Evaluating Media Features in a Boolean Context</h4>
   496 	While <a>media features</a> normally have a syntax similar to CSS properties,
   497 	they can also be written more simply as just the feature name,
   498 	like ''(color)''.
   500 	When written like this, the <a>media feature</a> is evaluated in a <dfn export>boolean context</dfn>.
   501 	If the feature would be true for any value
   502 	<em>other than</em> the number ''0'',
   503 	a <a spec=css-values>dimension</a> with the value ''0'',
   504 	or the keyword ''none'',
   505 	the <a>media feature</a> evaluates to true.
   506 	Otherwise, it evaluates to false.
   508 	<div class='example'>
   509 		Some <a>media features</a> are designed to be written like this.
   511 		For example, 'scripting' is typically written as ''(scripting)'' to test if scripting is enabled,
   512 		or ''not (scripting)'' to see if it's disabled.
   514 		It can still be given an explicit value as well,
   515 		with ''(scripting: enabled)'' equal to ''(scripting)'',
   516 		and ''(scripting: none)'' equal to ''not (scripting)''.
   517 	</div>
   519 	<div class='example'>
   520 		Some numeric <a>media features</a>, like 'width',
   521 		are rarely if ever useful to evaluate in a <a>boolean context</a>,
   522 		as their values are almost always greater than zero.
   523 		Others, like 'color', have meaningful zero values:
   524 		''(color)'' is identical to ''(color > 0)'',
   525 		indicating that the device is capable of displaying color at all.
   526 	</div>
   528 	<div class='example'>
   529 		Only some of the <a>media features</a> that accept keywords are meaningful in a <a>boolean context</a>.
   531 		For example, ''(pointer)'' is useful,
   532 		as 'pointer' has a ''pointer/none'' value to indicate there's no pointing device at all on the device.
   533 		On the other hand, ''(scan)'' is just always true or always false
   534 		(depending on whether it applies at all to the device),
   535 		as there's no value that means “false”.
   536 	</div>
   538 <!--
   539 ████████     ███    ██    ██  ██████   ████████
   540 ██     ██   ██ ██   ███   ██ ██    ██  ██
   541 ██     ██  ██   ██  ████  ██ ██        ██
   542 ████████  ██     ██ ██ ██ ██ ██   ████ ██████
   543 ██   ██   █████████ ██  ████ ██    ██  ██
   544 ██    ██  ██     ██ ██   ███ ██    ██  ██
   545 ██     ██ ██     ██ ██    ██  ██████   ████████
   546 -->
   548 <h4 id="mq-range-context">
   549 Evaluating Media Features in a Range Context</h4>
   552 	<a>Media features</a> with a “range” type can be alternately written in a <dfn export>range context</dfn>
   553 	that takes advantage of the fact that their values are ordered,
   554 	using ordinary mathematical comparison operators:
   556 	<pre class='railroad'>
   557 	T: (
   558 	Choice:
   559 		Seq:
   560 			N: feature name/value
   561 			Choice: 4
   562 				T: =
   563 				T: <
   564 				T: <=
   565 				T: >
   566 				T: >=
   567 			N: feature value/name
   568 		Seq:
   569 			N: value
   570 			Choice:
   571 				T: <
   572 				T: <=
   573 			N: feature name
   574 			Choice:
   575 				T: <
   576 				T: <=
   577 			N: value
   578 		Seq:
   579 			N: value
   580 			Choice:
   581 				T: >
   582 				T: >=
   583 			N: feature name
   584 			Choice:
   585 				T: >
   586 				T: >=
   587 			N: value
   588 	T: )
   589 	</pre>
   591 	The basic form,
   592 	consisting of a feature name,
   593 	a comparison operator,
   594 	and a value,
   595 	returns true if the relationship is true.
   597 	<div class='example'>
   598 		For example, ''(height > 600px)''
   599 		(or ''(600px &lt; height)'')
   600 		returns true if the viewport height is greater than ''600px''.
   601 	</div>
   603 	The remaining forms,
   604 	with the feature name nested between two value comparisons,
   605 	returns true if both comparisons are true.
   607 	<div class='example'>
   608 		For example, ''(400px &lt; width &lt; 1000px)'' returns true if the viewport width is between ''400px'' and ''1000px''
   609 		(but not equal to either).
   610 	</div>
   612 <!--
   613 ██     ██ ████ ██    ██       ██ ██     ██    ███    ██     ██
   614 ███   ███  ██  ███   ██      ██  ███   ███   ██ ██    ██   ██
   615 ████ ████  ██  ████  ██     ██   ████ ████  ██   ██    ██ ██
   616 ██ ███ ██  ██  ██ ██ ██    ██    ██ ███ ██ ██     ██    ███
   617 ██     ██  ██  ██  ████   ██     ██     ██ █████████   ██ ██
   618 ██     ██  ██  ██   ███  ██      ██     ██ ██     ██  ██   ██
   619 ██     ██ ████ ██    ██ ██       ██     ██ ██     ██ ██     ██
   620 -->
   622 <h4 id='mq-min-max'>
   623 Using “min-” and “max-” Prefixes On Range Features</h4>
   625 	Rather than evaluating a “range” type <a>media feature</a> in a range context,
   626 	as described above,
   627 	the feature may be written as a normal <a>media feature</a>,
   628 	but with a “min-” or “max-” prefix on the feature name.
   630 	This is equivalent to evaluating the feature in a <a>range context</a>,
   631 	as follows:
   633 	<ul>
   634 		<li>
   635 			Using a “min-” prefix on a feature name is equivalent to using the “>=” operator.
   636 			For example, ''(min-height: 600px)'' is equivalent to <span class=css data-link-type=maybe>(height >= 600px)</span>.
   638 		<li>
   639 			Using a “max-” prefix on a feature name is equivalent to using the “<=” operator.
   640 			For example, ''(max-width: 40em)'' is equivalent to <span class=css data-link-type=maybe>(width <= 40em)</span>.
   641 	</ul>
   643 	“Discrete” type properties do not accept “min-” or “max-” prefixes.
   644 	Adding such a prefix to a “discrete” type <a>media feature</a> simply results in an unknown feature name.
   646 	<div class='example'>
   647 		For example,
   648 		''(min-grid: 1)'' is invalid,
   649 		because 'grid' is a “discrete” <a>media feature</a>,
   650 		and so doesn't accept the prefixes.
   651 		(Even though the 'grid' <a>media feature</a> appears to be numeric,
   652 		as it accepts the values ''0'' and ''1''.)
   653 	</div>
   655 	Attempting to evaluate a min/max prefixed <a>media feature</a> in a <a>boolean context</a>
   656 	is invalid and a syntax error.
   659 Combining Media Features {#media-conditions}
   660 --------------------------------------------
   662 	Multiple <a>media features</a> can be combined together into a <dfn export>media condition</dfn>
   663 	using full boolean algebra
   664 	(not, and, or).
   666 	Issue: TODO: Fill this in.
   668 <!--
   669  ██████  ██    ██ ██    ██ ████████    ███    ██     ██
   670 ██    ██  ██  ██  ███   ██    ██      ██ ██    ██   ██
   671 ██         ████   ████  ██    ██     ██   ██    ██ ██
   672  ██████     ██    ██ ██ ██    ██    ██     ██    ███
   673       ██    ██    ██  ████    ██    █████████   ██ ██
   674 ██    ██    ██    ██   ███    ██    ██     ██  ██   ██
   675  ██████     ██    ██    ██    ██    ██     ██ ██     ██
   676 -->
   678 <h2 id='mq-syntax'>
   679 Syntax</h2>
   681 	Informal descriptions of the media query syntax appear in the prose and railroad diagrams in previous sections.
   682 	The formal media query syntax is described in this section,
   683 	with the rule/property grammar syntax defined in [[!CSS3SYN]] and [[!CSS3VAL]].
   685 	To parse a <dfn>&lt;media-query-list></dfn> production,
   686 	<a>parse a comma-separated list of component values</a>,
   687 	then parse each entry in the returned list as a <<media-query>>.
   688 	Its value is the list of <<media-query>>s so produced.
   690 	Note: This explicit definition of <<media-query-list>> parsing
   691 	is necessary to make the error-recovery behavior of <a>media query lists</a> well-defined.
   693 	Note: This definition of <<media-query-list>> parsing intentionally accepts an empty list.
   695 	<pre>
   696 	<dfn>&lt;media-query></dfn> = <<media-condition>>
   697 	             | [ not | only ]? <<media-type>> [ and <<media-condition-without-or>> ]?
   698 	<dfn>&lt;media-type></dfn> = <<ident>>
   700 	<dfn>&lt;media-condition></dfn> = <<media-not>> | <<media-and>> | <<media-or>> | <<media-in-parens>>
   701 	<dfn>&lt;media-condition-without-or></dfn> = <<media-not>> | <<media-and>> | <<media-in-parens>>
   702 	<dfn>&lt;media-not></dfn> = not <<media-in-parens>>
   703 	<dfn>&lt;media-and></dfn> = <<media-in-parens>> [ and <<media-in-parens>> ]+
   704 	<dfn>&lt;media-or></dfn> = <<media-in-parens>> [ or <<media-in-parens>> ]+
   705 	<dfn>&lt;media-in-parens></dfn> = ( <<media-condition>> ) | <<media-feature>> | <<general-enclosed>>
   707 	<dfn>&lt;media-feature></dfn> = ( [ <<mf-plain>> | <<mf-boolean>> | <<mf-range>> ] )
   708 	<dfn>&lt;mf-plain></dfn> = <<mf-name>> : <<mf-value>>
   709 	<dfn>&lt;mf-boolean></dfn> = <<mf-name>>
   710 	<dfn>&lt;mf-range></dfn> = <<mf-name>> [ '<' | '>' ]? '='? <<mf-value>>
   711 	           | <<mf-value>> [ '<' | '>' ]? '='? <<mf-name>>
   712 	           | <<mf-value>> '<' '='? <<mf-name>> '<' '='? <<mf-value>>
   713 	           | <<mf-value>> '>' '='? <<mf-name>> '>' '='? <<mf-value>>
   714 	<dfn>&lt;mf-name></dfn> = <<ident>>
   715 	<dfn>&lt;mf-value></dfn> = <<number>> | <<dimension>> | <<ident>> | <<ratio>>
   717 	<dfn>&lt;general-enclosed></dfn> = [ <<function-token>> <<any-value>> ) ] | ( <<ident>> <<any-value>> )
   718 	</pre>
   720 	The <<media-type>> production does not include the keywords ''only'', ''not'', ''and'', and ''or''.
   721 	A <dfn>&lt;dimension></dfn> is a <a spec=css-values>dimension</a>.
   722 	An <dfn>&lt;ident></dfn> is an <a>identifier</a>.
   724 	No whitespace is allowed between the "<" or ">" <<delim-token>>s and the following "=" <<delim-token>>,
   725 	if it's present.
   726 	Whitespace <em>must</em> be present between a ')' character and a  ''not'', ''and'', or ''or'' keyword,
   727 	and between a ''not'', ''and'', or ''or'' keyword and a '(' character.
   729 	When parsing the <<media-in-parens>> production,
   730 	the <<general-enclosed>> branch must only be chosen if the input does not match either of the preceding branches.
   731 	<span class='note'><<general-enclosed>> exists to allow for future expansion of the grammar in a reasonably compatible way.</span>
   733 	In addition to conforming to the syntax, each media query needs to use
   734 	media types and media features according to their respective specification
   735 	in order to be considered conforming.
   737 	<div class="example">
   738 		Only the first media query is conforming in the example below because the
   739 		"example" media type does not exist.
   741 		<pre>
   742 		@media all { body { background:lime } }
   743 		@media example { body { background:red } }
   744 		</pre>
   745 	</div>
   747 	Each of the major terms of <<media-condition>> or <<media-condition-without-or>> is associated with a boolean result, as follows:
   749 	<dl>
   750 		<dt><<media-condition>>
   751 		<dt><<media-condition-without-or>>
   752 		<dt><<media-in-parens>>
   753 		<dd>
   754 			The result is the result of the child term.
   756 		<dt><<media-not>>
   757 		<dd>
   758 			The result is the negation of the <<media-in-parens>> term.
   759 			The negation of unknown is unknown.
   761 		<dt><<media-and>>
   762 		<dd>
   763 			The result is true if all of the <<media-in-parens>> child terms are true,
   764 			false if at least one of the <<media-in-parens>> child terms are false,
   765 			and unknown otherwise.
   767 		<dt><<media-or>>
   768 		<dd>
   769 			The result is false if all of the <<media-in-parens>> child terms are false,
   770 			true if at least one of the <<media-in-parens>> child terms are true,
   771 			and unknown otherwise.
   773 		<dt><<general-enclosed>>
   774 		<dd>
   775 			The result is unknown.
   777 			Authors must not use <<general-enclosed>> in their stylesheets.
   778 			<span class='note'>It exists only for future-compatibility,
   779 			so that new syntax additions do not invalidate too much of a <<media-condition>> in older user agents.</span>
   781 		<dt><<media-feature>>
   782 		<dd>
   783 			The result is the result of evaluating the specified media feature.
   784 	</dl>
   786 	If the result of any of the above productions
   787 	is used in any context that expects a two-valued boolean,
   788 	"unknown" must be converted to "false".
   790 	Note: This means that,
   791 	for example,
   792 	when a <a>media query</a> is used in a ''@media'' rule,
   793 	if it resolves to "unknown" it's treated as "false"
   794 	and fails to match.
   796 	<div class="note">
   797 		Media Queries use a three-value logic where terms can be "true", "false", or "unknown".
   798 		Specifically, it uses the <a href="http://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics">Kleene 3-valued logic</a>.
   799 		In this logic, "unknown" means "either true or false, but we're not sure which yet".
   801 		In general, an unknown value showing up in a formula will cause the formula to be unknown as well,
   802 		as substituting "true" for the unknown will give the formula a different result than substituting "false".
   803 		The only way to eliminate an unknown value is to use it in a formula that will give the same result
   804 		whether the unknown is replaced with a true or false value.
   805 		This occurs when you have "false AND unknown" (evaluates to false regardless)
   806 		and "true OR unknown" (evaluates to true regardless).
   808 		This logic was adopted because <<general-enclosed>> needs to be assigned a truth value.
   809 		In standard boolean logic, the only reasonable value is "false",
   810 		but this means that ''not unknown(function)'' is true,
   811 		which can be confusing and unwanted.
   812 		Kleen's 3-valued logic ensures that unknown things will prevent a <a>media query</a> from matching,
   813 		unless their value is irrelevant to the final result.
   814 	</div>
   817 <h3 id="error-handling">
   818 Error Handling</h3>
   820 	A media query that does not match the grammar in the previous section must be replaced by ''not all'' during parsing.
   822 	Note: Note that a grammar mismatch does <strong>not</strong> wipe out an entire <a>media query list</a>,
   823 	just the problematic <a>media query</a>.
   824 	The parsing behavior defined above automatically recovers at the next top-level comma.
   826 	<div class='example'>
   827 		<pre>
   828 			@media (example, all,), speech { /* only applicable to speech devices */ }
   829 			@media &test, speech           { /* only applicable to speech devices */ }
   830 		</pre>
   832 		Both of the above <a>media query lists</a> are turned into ''not all, speech'' during parsing,
   833 		which has the same truth value as just ''speech''.
   835 		Note that error-recovery only happens at the top-level of a <a>media query</a>;
   836 		anything inside of an invalid parenthesized block
   837 		will just get turned into ''not all'' as a group.
   838 		For example:
   840 		<pre>
   841 			@media (example, speech { /* rules for speech devices */ }
   842 		</pre>
   844 		Because the parenthesized block is unclosed,
   845 		it will contain the entire rest of the stylesheet from that point
   846 		(unless it happens to encounter an unmatched ")" character somewhere in the stylesheet),
   847 		and turn the entire thing into a ''not all'' <a>media query</a>.
   848 	</div>
   850 	An unknown <<media-type>> must be treated as not matching.
   852 	<div class='example'>
   853 		For example, the media query ''unknown'' is false,
   854 		as ''unknown'' is an unknown <a>media type</a>.
   856 		But ''not unknown'' is true, as the ''not'' negates the false media type.
   857 	</div>
   859 	<div class='example'>
   860 		Remember that some keywords aren't allowed as <<media-type>>s
   861 		and cause parsing to fail entirely:
   862 		the media query ''or and (color)'' is turned into ''not all'' during parsing,
   863 		rather than just treating the ''or'' as an unknown <a>media type</a>.
   864 	</div>
   866 	An unknown <<mf-name>> or <<mf-value>>, or disallowed <<mf-value>>,
   867 	results in the value "unknown".
   868 	A <<media-query>> whose value is "unknown" must be replaced with ''not all''.
   870 	<div class="example">
   871 		<pre>&lt;link media="screen and (max-weight: 3kg) and (color), (color)"
   872 		      rel="stylesheet" href="example.css" /&gt;</pre>
   874 		As ''max-weight'' is an unknown <a>media feature</a>,
   875 		this <a>media query list</a> is turned into ''not all, (color)'',
   876 		which is equivalent to just ''(color)''.
   877 	</div>
   879 	<div class="example">
   880 		<pre>@media (min-orientation:portrait) { … }</pre>
   882 		The 'orientation' feature does not accept prefixes,
   883 		so this is considered an unknown <a>media feature</a>,
   884 		and turned into ''not all''.
   885 	</div>
   887 	<div class="example">
   888 		The media query ''(color:20example)'' specifies an unknown value for the 'color' media feature
   889 		and is therefore turned into ''not all''.
   890 	</div>
   892 	<div class="example">
   893 		This media query is turned into ''not all'' because negative lengths are not allowed for the 'width' media feature:
   895 		<pre>@media (min-width: -100px) { … }</pre>
   896 	</div>
   898 	<div class='note'>
   899 		Note that <a>media queries</a> are also subject to the parsing rules of the host language.
   900 		For example, take the following CSS snippet:
   902 		<pre> @media test;,all { body { background:lime } }</pre>
   904 		The media query ''test;,all'' is, parsed by itself,
   905 		equivalent to ''not all, all'', which is always true.
   906 		However, CSS's parsing rules cause the ''@media'' rule,
   907 		and thus the <a>media query</a>,
   908 		to end at the semicolon.
   909 		The remainder of the text is treated as a style rule
   910 		with an invalid selector and contents.
   911 	</div>
   913 <!--
   914 ████████  ████ ██     ██ ████████ ██    ██  ██████  ████  ███████  ██    ██  ██████
   915 ██     ██  ██  ███   ███ ██       ███   ██ ██    ██  ██  ██     ██ ███   ██ ██    ██
   916 ██     ██  ██  ████ ████ ██       ████  ██ ██        ██  ██     ██ ████  ██ ██
   917 ██     ██  ██  ██ ███ ██ ██████   ██ ██ ██  ██████   ██  ██     ██ ██ ██ ██  ██████
   918 ██     ██  ██  ██     ██ ██       ██  ████       ██  ██  ██     ██ ██  ████       ██
   919 ██     ██  ██  ██     ██ ██       ██   ███ ██    ██  ██  ██     ██ ██   ███ ██    ██
   920 ████████  ████ ██     ██ ████████ ██    ██  ██████  ████  ███████  ██    ██  ██████
   921 -->
   923 <h2 id="mf-dimensions">
   924 Screen/Device Dimensions Media Features</h2>
   926 <h3 id="width">
   927 width</h3>
   929 	<pre class='descdef mq'>
   930 	Name: width
   931 	Value: <<length>>
   932 	For: @media
   933 	Type: range
   934 	</pre>
   936 	The '@media/width' media feature describes the width of the targeted display area of the output device.
   937 	For continuous media, this is the width of the viewport
   938 	(as described by CSS2, section 9.1.1 [[!CSS21]])
   939 	including the size of a rendered scroll bar (if any).
   940 	For paged media, this is the width of the page box
   941 	(as described by CSS2, section 13.2 [[!CSS21]]).
   943 	A specified <<length>> cannot be negative.
   945 	<div class="example">
   946 		For example, this media query expresses that the style sheet is usable on printed output wider than 25cm:
   948 		<pre>&lt;link rel="stylesheet" media="print and (min-width: 25cm)" href="http://…" /></pre>
   949 	</div>
   951 	<div class="example">
   952 		This media query expresses that the style sheet is usable on devices with viewport
   953 		(the part of the screen/paper where the document is rendered)
   954 		widths between 400 and 700 pixels:
   956 		<pre>@media (400px <= min-width <= 700px) { … }</pre>
   957 	</div>
   959 	<div class="example">
   960 		This media query expresses that style sheet is usable if the width of the viewport is greater than 20em.
   962 		<pre>@media (min-width: 20em) { … }</pre>
   964 		The ''em'' value is relative to the initial value of 'font-size'.
   965 	</div>
   968 <h3 id="height">
   969 height</h3>
   971 	<pre class='descdef mq'>
   972 	Name: height
   973 	Value: <<length>>
   974 	For: @media
   975 	Type: range
   976 	</pre>
   978 	The 'height' media feature describes the height of the targeted display area of the output device.
   979 	For continuous media, this is the height of the viewport including the size of a rendered scroll bar (if any).
   980 	For paged media, this is the height of the page box.
   982 	A specified <<length>> cannot be negative.
   985 <h3 id='aspect-ratio'>
   986 aspect-ratio</h3>
   988 	<pre class='descdef mq'>
   989 	Name: aspect-ratio
   990 	Value: <<ratio>>
   991 	For: @media
   992 	Type: range
   993 	</pre>
   995 	The 'aspect-ratio' media feature is defined as the ratio of the value of the 'width' media feature
   996 	to the value of the 'height' media feature.
   999 <h3 id='orientation'>
  1000 orientation</h3>
  1002 	<pre class='descdef mq'>
  1003 	Name: orientation
  1004 	Value: portrait | landscape
  1005 	For: @media
  1006 	Type: discrete
  1007 	</pre>
  1009 	<dl dfn-type=value dfn-for="@media/orientation">
  1010 		<dt><dfn>portrait</dfn>
  1011 		<dd>The 'orientation' media feature is ''portrait''
  1012 		when the value of the 'height' media feature is greater than or equal to
  1013 		the value of the 'width' media feature.
  1014 		<dt><dfn>landscape</dfn>
  1015 		<dd>Otherwise 'orientation' is ''landscape''.
  1016 	</dl>
  1018 	<div class="example">
  1019 		The following media query tests for “portrait” orientation,
  1020 		like a phone held upright.
  1022 		<pre>@media (orientation:portrait) { … }</pre>
  1023 	</div>
  1025 <!--
  1026 ████████  ████  ██████  ████████         ███████  ██     ██    ███    ██       ████ ████████ ██    ██
  1027 ██     ██  ██  ██    ██ ██     ██       ██     ██ ██     ██   ██ ██   ██        ██     ██     ██  ██
  1028 ██     ██  ██  ██       ██     ██       ██     ██ ██     ██  ██   ██  ██        ██     ██      ████
  1029 ██     ██  ██   ██████  ████████        ██     ██ ██     ██ ██     ██ ██        ██     ██       ██
  1030 ██     ██  ██        ██ ██              ██  ██ ██ ██     ██ █████████ ██        ██     ██       ██
  1031 ██     ██  ██  ██    ██ ██              ██    ██  ██     ██ ██     ██ ██        ██     ██       ██
  1032 ████████  ████  ██████  ██               █████ ██  ███████  ██     ██ ████████ ████    ██       ██
  1033 -->
  1035 <h2 id='mf-display-quality'>
  1036 Display Quality Media Features</h2>
  1038 <h3 id="resolution">
  1039 resolution</h3>
  1041 	<pre class='descdef mq'>
  1042 	Name: resolution
  1043 	Value: <<resolution>>
  1044 	For: @media
  1045 	Type: range
  1046 	</pre>
  1048 	The 'resolution' media feature describes the resolution of the output
  1049 	device, i.e. the density of the pixels, taking into account the <a
  1050 	spec=cssom-view>page zoom</a> but assuming a <a spec=cssom-view>pinch zoom</a>
  1051 	of 1.0.
  1053 	When querying media with non-square pixels, 'resolution' queries the density in the vertical dimension.
  1055 	<div class="note"><<resolution>> does not refer to the number of device
  1056 	pixels per physical length unit, but the number of device pixels per css
  1057 	pixels. This mapping is done by the user agent, so it is always known to the
  1058 	user agent.
  1060 	If the user agent either has no knowledge of the geometry of physical pixels,
  1061 	or knows about the geometry physical pixels and they are (close enough to)
  1062 	square, it would not map a different number of device pixels per css pixels
  1063 	along each axis, and the would therefore be no difference between the vertical
  1064 	and horizontal resolution.
  1066 	Otherwise, if the UA choses to map a different number along each axis,
  1067 	this would be to respond to physical pixels not being square either. How
  1068 	the UA comes to this knowledge is out of scope, but having enough information
  1069 	to take this decision, it can invert the mapping should the device be rotated 90 degrees.</div>
  1071 	For printers, this corresponds to the screening resolution
  1072 	(the resolution for printing dots of arbitrary color).
  1073 	Printers might have a different resolution for grayscale printing.
  1075 	<div class='example'>
  1076 		This media query simply detects “high-resolution” screens
  1077 		(those with a hardware pixel to CSS ''px'' ratio of at least 2):
  1079 		<pre>@media (resolution >= 2dppx)</pre>
  1080 	</div>
  1082 	<div class="example">
  1083 		For example, this media query expresses that a style sheet is usable on devices with resolution greater than 300 dots per CSS ''in'':
  1085 		<pre>@media print and (min-resolution: 300dpi) { … }</pre>
  1087 		This media query is equivalent, but uses the CSS ''cm'' unit:
  1089 		<pre>@media print and (min-resolution: 118dpcm) { … }</pre>
  1090 	</div>
  1093 <h3 id="scan">
  1094 scan</h3>
  1096 	<pre class='descdef mq'>
  1097 	Name: scan
  1098 	Value: interlace | progressive
  1099 	For: @media
  1100 	Type: discrete
  1101 	</pre>
  1103 	The 'scan' media feature describes the scanning process of some output devices.
  1105 	<dl dfn-type=value dfn-for="@media/scan">
  1106 		<dt><dfn>interlace</dfn>
  1107 		<dd>
  1108 			CRT and some types of plasma TV screens used “interlaced” rendering,
  1109 			where video frames alternated between specifying only the “even” lines on the screen
  1110 			and only the “odd” lines,
  1111 			exploiting various automatic mental image-correction abilities to produce smooth motion.
  1112 			This allowed them to simulate a higher FPS broadcast at half the bandwidth cost.
  1114 			When displaying on interlaced screens,
  1115 			authors should avoid very fast movement across the screen to avoid “combing”,
  1116 			and should ensure that details on the screen are wider than ''1px'' to avoid <a href="https://en.wikipedia.org/wiki/Interlaced_video#Interline_twitter">“twitter”</a>.
  1118 		<dt><dfn>progressive</dfn>
  1119 		<dd>
  1120 			A screen using “progressive” rendering displays each screen fully,
  1121 			and needs no special treatment.
  1123 			Most modern screens, and all computer screens, use progressive rendering.
  1124 	</dl>
  1126 	<div class="example">
  1127 		For example, the “feet” of letters in serif fonts are very small features that can provoke “twitter” on interlaced devices.
  1128 		The '@media/scan' media feature can be used to detect this,
  1129 		and use an alternative font with less chance of “twitter”:
  1131 		<pre>@media (scan: interlace) { body { font-family: sans-serif; } }</pre>
  1132 	</div>
  1134 <h3 id="grid">
  1135 grid</h3>
  1137 	<pre class='descdef mq'>
  1138 	Name: grid
  1139 	Value: <<mq-boolean>>
  1140 	For: @media
  1141 	Type: discrete
  1142 	</pre>
  1144 	The 'grid' media feature is used to query whether the output device is grid or bitmap.
  1145 	If the output device is grid-based
  1146 	(e.g., a "tty" terminal, or a phone display with only one fixed font),
  1147 	the value will be 1.
  1148 	Otherwise, the value will be 0.
  1150 	<div class="example">
  1151 		Here is an example that detects a narrow console screen:
  1153 		<pre>
  1154 		@media (grid) and (max-width: 15em) { … }
  1155 		</pre>
  1156 	</div>
  1158 <h3 id="update-frequency">
  1159 update-frequency</h3>
  1161 	<pre class='descdef mq'>
  1162 	Name: update-frequency
  1163 	Value: none | slow | normal
  1164 	For: @media
  1165 	Type: discrete
  1166 	</pre>
  1168 	The 'update-frequency' media feature is used to query the ability of the output device
  1169 	to modify the apearance of content once it has been rendered.
  1170 	It accepts the following values:
  1172 	<dl dfn-type=value dfn-for="@media/update-frequency">
  1173 		<dt><dfn>none</dfn>
  1174 		<dd>
  1175 			Once it has been rendered, the layout can no longer be updated.
  1176 			Example: documents printed on paper.
  1178 		<dt><dfn>slow</dfn>
  1179 		<dd>
  1180 			The layout may change dynamically according to the usual rules of CSS,
  1181 			but the output device is not able to render or display changes quickly enough
  1182 			for them to be percieved as a smooth animation.
  1183 			Example: E-ink screens or severely under-powered devices.
  1185 		<dt><dfn>normal</dfn>
  1186 		<dd>
  1187 			The layout may change dynamically according to the usual rules of CSS,
  1188 			and the output device is not unusually constrained in speed,
  1189 			so regularly-updating things like CSS Animations can be used.
  1190 			Example: computer screens.
  1191 	</dl>
  1193 	<div class='example'>
  1194 		For example, if a page styles its links to only add underlines on hover,
  1195 		it may want to always display underlines when printed:
  1197 		<pre>
  1198 		a { text-decoration: none; }
  1199 		a:hover, a:focus { text-decoration: underline; }
  1200 		@media (update-frequency: none) {
  1201 			a { text-decoration: underline; }
  1203 		</pre>
  1204 	</div>
  1206 <h3 id='mf-overflow-block'>
  1207 overflow-block</h3>
  1209 	<pre class='descdef mq'>
  1210 	Name: overflow-block
  1211 	Value: none | scroll | optional-paged | paged
  1212 	For: @media
  1213 	Type: discrete
  1214 	</pre>
  1216 	The 'overflow-block' media feature describes the behavior of the device
  1217 	when content overflows the initial containing block in the <a>block axis</a>.
  1219 	<dl dfn-type=value dfn-for="@media/overflow-block">
  1220 		<dt><dfn>none</dfn>
  1221 		<dd>
  1222 			There is no affordance for overflow in the <a>block axis</a>;
  1223 			any overflowing content is simply not displayed.
  1224 			Examples: billboards
  1226 		<dt><dfn>scroll</dfn>
  1227 		<dd>
  1228 			Overflowing content in the <a>block axis</a> is exposed by allowing users to scroll to it.
  1229 			Examples: computer screens
  1231 		<dt><dfn>optional-paged</dfn>
  1232 		<dd>
  1233 			Overflowing content in the <a>block axis</a> is exposed by allowing users to scroll to it,
  1234 			but page breaks can be manually triggered
  1235 			(such as via 'break-inside'/etc)
  1236 			to cause the following content to display on the following page.
  1237 			Examples: slideshows
  1239 		<dt><dfn>paged</dfn>
  1240 		<dd>
  1241 			Content is broken up into discrete pages;
  1242 			content that overflows one page in the <a>block axis</a>
  1243 			is displayed on the following page.
  1244 			Examples: printers, ebook readers
  1245 	</dl>
  1247 <h3 id='mf-overflow-inline'>
  1248 overflow-inline</h3>
  1250 	<pre class="descdef mq">
  1251 	Name: overflow-inline
  1252 	Value: none | scroll
  1253 	For: @media
  1254 	Type: discrete
  1255 	</pre>
  1257 	The 'overflow-inline' media feature describes the behavior of the device
  1258 	when content overflows the initial containing block in the <a>inline axis</a>.
  1260 	<dl dfn-type=value dfn-for="@media/overflow-inline">
  1261 		<dt><dfn>none</dfn>
  1262 		<dd>
  1263 			There is no affordance for overflow in the <a>inline axis</a>;
  1264 			any overflowing content is simply not displayed.
  1266 		<dt><dfn>scroll</dfn>
  1267 		<dd>
  1268 			Overflowing content in the <a>inline axis</a> is exposed by allowing users to scroll to it.
  1269 	</dl>
  1271 	Note: There are no known implementations of paged overflow of inline-overflowing content,
  1272 	and the very concept doesn't seem to make much sense,
  1273 	so there is intentionally no ''paged'' value for '@media/overflow-inline'.
  1276 <!--
  1277  ██████   ███████  ██        ███████  ████████
  1278 ██    ██ ██     ██ ██       ██     ██ ██     ██
  1279 ██       ██     ██ ██       ██     ██ ██     ██
  1280 ██       ██     ██ ██       ██     ██ ████████
  1281 ██       ██     ██ ██       ██     ██ ██   ██
  1282 ██    ██ ██     ██ ██       ██     ██ ██    ██
  1283  ██████   ███████  ████████  ███████  ██     ██
  1284 -->
  1286 <h2 id='mf-colors'>
  1287 Color Media Features</h2>
  1290 <h3 id="color">
  1291 color</h3>
  1293 	<pre class='descdef mq'>
  1294 	Name: color
  1295 	Value: <<integer>>
  1296 	For: @media
  1297 	Type: range
  1298 	</pre>
  1300 	The 'color' media feature describes the number of bits per color component of the output device.
  1301 	If the device is not a color device, the value is zero.
  1303 	A specified <<integer>> cannot be negative.
  1305 	<div class="example">
  1306 		For example, these two media queries express that a style sheet applies to all color devices:
  1308 		<pre>
  1309 		@media (color) { … }
  1310 		@media (min-color: 1) { … }
  1311 		</pre>
  1312 	</div>
  1314 	<div class="example">
  1315 		This media query expresses that a style sheet applies to color devices
  1316 		with at least 8 bits per color component:
  1318 		<pre>@media (color >= 8) { … }</pre>
  1319 	</div>
  1321 	If different color components are represented by different number of bits,
  1322 	the smallest number is used.
  1324 	<div class="example">
  1325 		For instance, if an 8-bit color system
  1326 		represents the red component with 3 bits, the green component with 3 bits, and the blue component with 2 bits,
  1327 		the '@media/color' media feature will have a value of 2.
  1328 	</div>
  1330 	In a device with indexed colors,
  1331 	the minimum number of bits per color component in the lookup table is used.
  1333 	Note: The described functionality is only able to describe color capabilities at a superficial level.
  1334 	If further functionality is required,
  1335 	RFC2531 [[RFC2531]] provides more specific media features which may be supported at a later stage.
  1338 <h3 id="color-index">
  1339 color-index</h3>
  1341 	<pre class='descdef mq'>
  1342 	Name: color-index
  1343 	Value: <<integer>>
  1344 	For: @media
  1345 	Type: range
  1346 	</pre>
  1348 	The 'color-index' media feature describes the number of entries in the color lookup table of the output device.
  1349 	If the device does not use a color lookup table, the value is zero.
  1351 	A specified <<integer>> cannot be negative.
  1353 	<div class="example">
  1354 		For example, here are two ways to express that a style sheet applies to all color index devices:
  1356 		<pre>
  1357 		@media (color-index) { … }
  1358 		@media (color-index >= 1) { … }
  1359 		</pre>
  1360 	</div>
  1363 	<div class="example">
  1364 		This media query expresses that a style sheet applies to a color index device with 256 or more entries:
  1366 		<pre>
  1367 		&lt;?xml-stylesheet media="(min-color-index: 256)"
  1368 			href="http://www.example.com/…" ?>
  1369 		</pre>
  1370 	</div>
  1372 <h3 id="monochrome">
  1373 monochrome</h3>
  1375 	<pre class='descdef mq'>
  1376 	Name: monochrome
  1377 	Value: <<integer>>
  1378 	For: @media
  1379 	Type: range
  1380 	</pre>
  1382 	The 'monochrome' media feature describes the number of bits per pixel in a monochrome frame buffer.
  1383 	If the device is not a monochrome device,
  1384 	the output device value will be 0.
  1386 	A specified <<integer>> cannot be negative.
  1388 	<div class="example">
  1389 		For example, this is how to express that a style sheet applies to all monochrome devices:
  1391 		<pre>@media (monochrome) { … }</pre>
  1392 	</div>
  1394 	<div class="example">
  1395 		Express that a style sheet applies to monochrome devices with more than 2 bits per pixels:
  1397 		<pre>@media (monochrome >= 2) { … }</pre>
  1398 	</div>
  1401 	<div class="example">
  1402 		Express that there is one style sheet for color pages and another for monochrome:
  1404 		<pre>
  1405 		&lt;link rel="stylesheet" media="print and (color)" href="http://…" />
  1406 		&lt;link rel="stylesheet" media="print and (monochrome)" href="http://…" />
  1407 		</pre>
  1408 	</div>
  1410 <h3 id="inverted">
  1411 inverted-colors</h3>
  1413 	<pre class='descdef mq'>
  1414 	Name: inverted-colors
  1415 	Value: none | inverted
  1416 	For: @media
  1417 	Type: discrete
  1418 	</pre>
  1420 	The 'inverted-colors' media feature indicates whether the content is displayed normally, or whether colors have been inverted.
  1422 	<p class="note">This is an indication that the user agent or underlying
  1423 	operating system has forcibly inverted all colors, not a request to do so. This
  1424 	is sometimes provided as a simple accessibility feature, allowing users to
  1425 	switch between light-on-dark and dark-on-light text. However, this has
  1426 	unpleasant side effects, such as inverting pictures, or turning shadows into
  1427 	highlights, which reduce the readability of the content.
  1429 	<dl dfn-type=value dfn-for="@media/inverted-colors">
  1430 		<dt><dfn>none</dfn>
  1431 		<dd>
  1432 			Colors are displayed normally.
  1434 		<dt><dfn>inverted</dfn>
  1435 		<dd>
  1436 			All pixels within the displayed area have been inverted.
  1438 	</dl>
  1440 	<div class="example">
  1441 		For example, a user frequently using his operating system's
  1442 		ability to invert the screens color may want to add the following to his user
  1443 		style sheet, to limit the undesirable side effects of the inversion.
  1445 		<pre>@media (inverted-colors) {
  1446 			img { filter: invert(100%); }
  1447 			* { text-shadow: none; box-shadow: none; }
  1449 		</pre>
  1450 	</div>
  1453 <!--
  1454 ████ ██    ██ ████████ ████████ ████████     ███     ██████  ████████ ████  ███████  ██    ██
  1455  ██  ███   ██    ██    ██       ██     ██   ██ ██   ██    ██    ██     ██  ██     ██ ███   ██
  1456  ██  ████  ██    ██    ██       ██     ██  ██   ██  ██          ██     ██  ██     ██ ████  ██
  1457  ██  ██ ██ ██    ██    ██████   ████████  ██     ██ ██          ██     ██  ██     ██ ██ ██ ██
  1458  ██  ██  ████    ██    ██       ██   ██   █████████ ██          ██     ██  ██     ██ ██  ████
  1459  ██  ██   ███    ██    ██       ██    ██  ██     ██ ██    ██    ██     ██  ██     ██ ██   ███
  1460 ████ ██    ██    ██    ████████ ██     ██ ██     ██  ██████     ██    ████  ███████  ██    ██
  1461 -->
  1463 <h2 id='mf-interaction'>
  1464 Interaction Media Features</h2>
  1466 <h3 id="pointer">
  1467 pointer</h3>
  1469 	<pre class='descdef mq'>
  1470 	Name: pointer
  1471 	Value: none | coarse | fine
  1472 	For: @media
  1473 	Type: discrete
  1474 	</pre>
  1476 	The 'pointer' media feature is used to query about the presence and accuracy of a pointing device such as a mouse.
  1477 	If a device has multiple input mechanisms,
  1478 	the 'pointer' media feature must reflect the characteristics of the “primary” input mechanism,
  1479 	as determined by the user agent.
  1480 	(To query the capabilities of <em>any</em> available input mechanism,
  1481 		see the 'any-pointer' media feature.)
  1483 	<dl dfn-type=value dfn-for="@media/pointer">
  1484 		<dt><dfn>none</dfn>
  1485 		<dd>The primary input mechanism of the device does not include a pointing device.
  1487 		<dt><dfn>coarse</dfn>
  1488 		<dd>The primary input mechanism of the device includes a pointing device of limited accuracy.
  1490 		<dt><dfn>fine</dfn>
  1491 		<dd>The primary input mechanism of the device includes an accurate pointing device.
  1492 	</dl>
  1494 	Both ''coarse'' and ''fine'' indicate the presence of a pointing device,
  1495 	but differ in accuracy.
  1496 	A pointing device with which it would be difficult or impossible
  1497 	to reliably pick one of several small adjacent targets at a zoom factor of 1
  1498 	would qualify as ''coarse''.
  1499 	Changing the zoom level does not affect the value of this media feature.
  1501 	Note: As the UA may provide the user with the ability to zoom,
  1502 	or as secondary pointing devices may have a different accuracy,
  1503 	the user may be able to perform accurate clicks even if the value of this media feature is ''coarse''.
  1504 	This media feature does not indicate that the user will never be able to click accurately,
  1505 	only that it is inconvenient for them to do so.
  1506 	Authors are expected to react to a value of ''coarse''
  1507 	by designing pages that do not rely on accurate clicking to be operated.
  1509 	<div class='note'>
  1510 		Typical examples of devices matching combinations of 'pointer' and 'hover':
  1512 		<table id='pointer-hover-table'>
  1513 			<thead>
  1514 				<tr>
  1515 					<td><td><th colspan=2>pointer
  1516 				<tr>
  1517 					<td>
  1518 					<td>
  1519 					<th>coarse
  1520 					<th>fine
  1521 			<tbody>
  1522 				<tr>
  1523 					<th rowspan=2>hover
  1524 					<th>none
  1525 					<td>smartphones, touch screens
  1526 					<td>stylus-based screens (Cintiq, Wacom, etc)
  1527 				<tr>
  1528 					<th>hover
  1529 					<td>Nintendo Wii controller, Kinect
  1530 					<td>mouse, touch pad
  1531 		</table>
  1532 		<style>
  1533 			#pointer-hover-table { margin: 1em auto; text-align: center; border-collapse: collapse; max-width: 40em; }
  1534 			#pointer-hover-table td, #pointer-hover-table th { padding: .5em; }
  1535 			#pointer-hover-table thead tr+tr th { border-bottom: 1px solid silver; }
  1536 			#pointer-hover-table tbody td:first-of-type { border-left: 1px solid silver; }
  1537 		</style>
  1538 	</div>
  1540 	For accessibility reasons,
  1541 	even on devices whose pointing device can be described as ''fine'',
  1542 	the UA may give a value of ''coarse'' or ''pointer/none'' to this media query,
  1543 	to indicate that the user has difficulties manipulating the pointing device accurately or at all.
  1545 	<div class="example">
  1546 		<pre>
  1547 		/* Make radio buttons and check boxes larger if we have an inaccurate pointing device */
  1548 		@media (pointer:coarse) {
  1549 			input[type="checkbox"], input[type="radio"] {
  1550 				min-width:30px;
  1551 				min-height:40px;
  1552 				background:transparent;
  1555 		</pre>
  1556 	</div>
  1558 <h3 id="hover">
  1559 hover</h3>
  1561 	<pre class='descdef mq'>
  1562 	Name: hover
  1563 	Value: none | on-demand | hover
  1564 	For: @media
  1565 	Type: discrete
  1566 	</pre>
  1568 	The 'hover' media feature is used to query the user's ability to hover over elements on the page.
  1569 	If a device has multiple input mechanisms,
  1570 	the 'hover' media feature must reflect the characteristics of the “primary” input mechanism,
  1571 	as determined by the user agent.
  1572 	(To query the capabilities of <em>any</em> available input mechanism,
  1573 		see the 'any-hover' media feature.)
  1575 	<dl dfn-type=value dfn-for="@media/hover">
  1576 		<dt><dfn>none</dfn>
  1577 		<dd>
  1578 			Indicates that the primary pointing system can't hover,
  1579 			or there is no pointing system.
  1581 		<dt><dfn>on-demand</dfn>
  1582 		<dd>
  1583 			Indicates that the primary pointing system can hover,
  1584 			but it requires a significant action on the user's part.
  1585 			For example, some devices can't normally hover,
  1586 			but will activate hover on a “long press”.
  1588 		<dt><dfn>hover</dfn>
  1589 		<dd>
  1590 			Indicates that the primary pointing system can easily hover over parts of the page.
  1591 	</dl>
  1593 	<div class='example'>
  1594 		For example, on a touch screen device that can also be controlled by an optional mouse,
  1595 		the 'hover' <a>media feature</a> should match ''hover/none'',
  1596 		as the primary interaction mode (touching the screen) can't hover.
  1598 		Authors should therefore be careful not to assume that the ':hover' pseudo class
  1599 		will never match on device where 'hover:none' is true,
  1600 		but they should design layouts that do not depend on hovering to be fully usable.
  1601 	</div>
  1603 	For accessibility reasons, even on devices that do support hovering,
  1604 	the UA may give a value of ''hover: none'' to this media query,
  1605 	to opt into layouts that work well without hovering.
  1607 	<div class="example">
  1608 		<pre>
  1609 		/* Only use a hover-activated drop down menu on devices that can conveniently hover. */
  1610 		@media (hover) {
  1611 			.menu > li        {display:inline-block;}
  1612 			.menu ul          {display:none; position:absolute;}
  1613 			.menu li:hover ul {display:block; list-style:none; padding:0;}
  1614 			/* ... */
  1616 		</pre>
  1617 	</div>
  1619 <h3 id='any-input'>
  1620 any-pointer and any-hover</h3>
  1622 	<pre class='descdef mq'>
  1623 	Name: any-pointer
  1624 	Value: none | coarse | fine
  1625 	For: @media
  1626 	Type: discrete
  1627 	</pre>
  1629 	<pre class='descdef mq'>
  1630 	Name: any-hover
  1631 	Value: none | on-demand | hover
  1632 	For: @media
  1633 	Type: discrete
  1634 	</pre>
  1636 	The 'any-pointer' and 'any-hover' media features are identical to the 'pointer' and 'hover' media features,
  1637 	but they correspond to the union of capabilities of all the pointing devices available to the user.
  1638 	More than one of their values can match,
  1639 	if different pointing devices have different characteristics.
  1641 	<div class="note">
  1642 	These two media features are best suited to provide refinements over 'hover' and 'pointer',
  1643 	and it is rarely appropriate to use them
  1644 	without having first designed the main style and interaction mode of the page
  1645 	to suit the primary input mechanism.
  1646 	Once that has been taken into account, 'any-hover' and 'any-pointer' can be used
  1647 	to see if some extra conveniences or non essential controls
  1648 	can be offered to users who have additional ways to interact.
  1650 	Designing a page that relies on hovering or accurate pointing
  1651 	only because 'any-hover' or 'any-pointer' indicate that an input mechanism with these capabilities is available,
  1652 	is likely to result in a poor experience.
  1653 	</div>
  1655 	<div class="example">
  1656 	A number of smart TVs come with a way to control an on-screen cursor,
  1657 	but it is often fairly basic controller which is difficult to operate accurately.
  1659 	A browser in such a smart TV would have ''coarse'' as the value of both 'pointer' and 'any-pointer',
  1660 	allowing authors to provide a layout with large and easy to reach click targets.
  1662 	The user may also have paired a Bluetooth mouse with the TV,
  1663 	and occasionally use it for extra convenience,
  1664 	but such the mouse is not the main way the TV is operated.
  1665 	'pointer' still matches ''coarse'', while 'any-pointer' now both matches ''coarse'' and ''fine''.
  1667 	Switching to small click targets based on the fact that ''(any-pointer: fine)'' is now true
  1668 	would not be appropriate.
  1669 	It would not only surprise the user
  1670 	by providing an experience out of line with what they expect on a TV,
  1671 	but may also be quite inconvenient:
  1672 	the mouse, not being the primary way to control the TV, may be out of reach,
  1673 	hidden under one of the cushions on the sofa...
  1675 	By contrast, consider scrolling on the same TV.
  1676 	Scrollbars are difficult to manipulate without an accurate pointing device.
  1677 	Having prepared an alternative way to indicate that there is more content to be seen
  1678 	based on ''(pointer: coarse)'' being true,
  1679 	an author may want to still show the scrollbars in addition if ''(any-pointer: fine)'' is true,
  1680 	or to hide them altogether to reduce visual clutter if ''(any-pointer: fine)'' is false.
  1681 	</div>
  1684 <!--
  1685 ████████ ██    ██ ██     ██
  1686 ██       ███   ██ ██     ██
  1687 ██       ████  ██ ██     ██
  1688 ██████   ██ ██ ██ ██     ██
  1689 ██       ██  ████  ██   ██
  1690 ██       ██   ███   ██ ██
  1691 ████████ ██    ██    ███
  1692 -->
  1694 <h2 id='mf-environment'>
  1695 Environment Media Features</h2>
  1697 <h3 id="light-level">
  1698 light-level</h3>
  1700 	<pre class='descdef mq'>
  1701 	Name: light-level
  1702 	Value: dim | normal | washed
  1703 	For: @media
  1704 	Type: discrete
  1705 	</pre>
  1707 	The 'light-level' media feature is used to query about the ambient light-level in which the device is used,
  1708 	to allow the author to adjust style of the document in response.
  1709 	The following values are valid:
  1711 	<dl dfn-type=value dfn-for="@media/light-level">
  1712 		<dt><dfn>dim</dfn>
  1713 		<dd>
  1714 			The device is used in a dim environment,
  1715 			where excessive contrast and brightness would be distracting or uncomfortable to the reader.
  1716 			For example: night time, or a dimly illuminated indoor environment.
  1718 		<dt><dfn>normal</dfn>
  1719 		<dd>
  1720 			The device is used in a environment with a light level in the ideal range for the screen,
  1721 			and which does not necessitate any particular adjustment.
  1723 		<dt><dfn>washed</dfn>
  1724 		<dd>
  1725 			The device is used in an exceptionally bright environment,
  1726 			causing the screen to be washed out and difficult to read.
  1727 			For example: bright daylight.
  1728 	</dl>
  1730 	User agents should set the thresholds between the 3 levels
  1731 	in a way that takes into account the characteristics of the device.
  1733 	<div class="note">
  1734 		Even though it is expected that User Agents will adjust the value of this media feature
  1735 		based on ambient light sensors,
  1736 		this specification intentionally refrains from defining the 3 levels in terms of a measurement in lux,
  1737 		for several reasons:
  1739 		<ul>
  1740 			<li>
  1741 				Devices equipped with a light sensor usually adjust the brightness of the screen automatically.
  1742 				Depending on the level of adjustment,
  1743 				the thresholds for needing a low contrast or hight contrast content may vary.
  1745 			<li>
  1746 				Different screen technologies wash out at very different ambient light levels;
  1747 				e-ink displays remain readable in bright daylight,
  1748 				while liquid crystal displays do not.
  1750 			<li>
  1751 				Many embedded light sensors are inaccurately calibrated,
  1752 				making it difficult to establish useful thresholds valid across devices.
  1753 		</ul>
  1754 	</div>
  1756 	For accessibility purposes, user agents may offer manual controls
  1757 	allowing the user to switch between the 3 levels of independently of the ambient light level,
  1758 	as high contrast or low contrast styles may be more suitable for users with visual disabilities.
  1760 	<p class="issue">
  1761 		Using this media feature for accessibility purposes overlaps a lot with <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465764.aspx">the high-contrast media feature proposed by Microsoft</a>.
  1762 		Can we adjust this so that it covers all use cases for both,
  1763 		or somehow modify them to work in an orthogonal, rather than overlapping, fashion?
  1765 	<div class="example">
  1766 		<pre>
  1767 		@media (light-level: normal) {
  1768 			p { background: url("texture.jpg"); color: #333 }
  1770 		@media (light-level: dim) {
  1771 			p { background: #222; color: #ccc }
  1773 		@media (light-level: washed) {
  1774 			p { background: white; color: black; font-size: 2em; }
  1776 		</pre>
  1777 	</div>
  1779 <!--
  1780  ██████   ██████  ████████  ████ ████████  ████████ ████ ██    ██  ██████
  1781 ██    ██ ██    ██ ██     ██  ██  ██     ██    ██     ██  ███   ██ ██    ██
  1782 ██       ██       ██     ██  ██  ██     ██    ██     ██  ████  ██ ██
  1783  ██████  ██       ████████   ██  ████████     ██     ██  ██ ██ ██ ██   ████
  1784       ██ ██       ██   ██    ██  ██           ██     ██  ██  ████ ██    ██
  1785 ██    ██ ██    ██ ██    ██   ██  ██           ██     ██  ██   ███ ██    ██
  1786  ██████   ██████  ██     ██ ████ ██           ██    ████ ██    ██  ██████
  1787 -->
  1789 <h2 id='mf-scripting'>
  1790 Scripting Media Features</h2>
  1792 <h3 id="scripting">
  1793 scripting</h3>
  1795 	<pre class='descdef mq'>
  1796 	Name: scripting
  1797 	Value: none | initial-only | enabled
  1798 	For: @media
  1799 	Type: discrete
  1800 	</pre>
  1802 	The 'scripting' media feature is used to query whether scripting languages,
  1803 	such as JavaScript,
  1804 	are supported on the current document.
  1806 	<dl dfn-type=value dfn-for="@media/scripting">
  1807 		<dt><dfn>enabled</dfn>
  1808 		<dd>
  1809 			Indicates that the user agent supports scripting of the page
  1810 			and that support is active for the current document.
  1812 		<dt><dfn>initial-only</dfn>
  1813 		<dd>
  1814 			Indicates that scripting is enabled during the initial page load,
  1815 			but is not supported afterwards.
  1816 			Examples are printed pages,
  1817 			or pre-rendering network proxies
  1818 			that render a page on a server
  1819 			and send a nearly-static version of the page to the user.
  1821 		<dt><dfn>none</dfn>
  1822 		<dd>
  1823 			Indicates that the user agent will not run scripts for this document;
  1824 			either it doesn't support a scripting language,
  1825 			or the support isn't active for the current document.
  1826 	</dl>
  1828 	Some user agents have the ability to turn off scripting support on a per script basis or per domain basis,
  1829 	allowing some, but not all, scripts to run in a particular document.
  1830 	The 'scripting' media feature does not allow fine grained detection of which script is allowed to run.
  1831 	In this scenario, the value of the 'scripting' media feature should be ''scripting/enabled''
  1832 	if scripts originating on the same domain as the document are allowed to run,
  1833 	and ''scripting/none'' otherwise.
  1835 	Note: A future level of CSS may extend this media feature to allow fine-grained detection of which script is allowed to run.
  1837 <!--
  1838 ████  ██████   ██████  ██     ██ ████████  ██████
  1839  ██  ██    ██ ██    ██ ██     ██ ██       ██    ██
  1840  ██  ██       ██       ██     ██ ██       ██
  1841  ██   ██████   ██████  ██     ██ ██████    ██████
  1842  ██        ██       ██ ██     ██ ██             ██
  1843  ██  ██    ██ ██    ██ ██     ██ ██       ██    ██
  1844 ████  ██████   ██████   ███████  ████████  ██████
  1845 -->
  1847 <!--
  1848 <h2 id='assorted-issues'>
  1849 Assorted Issues</h2>
  1851 	<div class='issue'>
  1852 		We need a media feature (or set of media features) to detect the type of keyboard available.
  1853 		It should be able to distinguish between full computer keyboards, phone dial pads, tv remotes, or virtual keyboards.
  1854 		As an attempt at an exhaustive list is likely to fail,
  1855 		finding atomic features to decompose these into would be preferable,
  1856 		but these remain to be identified.
  1858 		<ul>
  1859 			<li>always vs in text forms only
  1860 			<li>just numbers vs free alphanumeric input vs full ime support
  1861 			<li>work properly vs horrible lag like on a tv remove
  1862 		</ul>
  1864 		How much is actually useful for styling?
  1865 	</div>
  1867 	<div class='issue'>
  1868 		Example sets of MQs that would match on different types of devices
  1870 		<ul>
  1871 			<li>printer: update-frequency:none, pointer:none, hover:none, overflow-block: paged, overflow-inline: none
  1872 			<li>eink with stylus: update-frequency:slow, pointer:fine, hover:none, overflow-block: paged, overflow-inline: none
  1873 			<li>tv: update-frequency: normal, pointer: none, hover: none: overflow-block: none, overflow-inline: none
  1874 			<li>tablet: update-frequency: normal, pointer coarse, hover none, overflow-block: scroll, overflow-inline: scroll
  1875 			<li>wii: update-frequency normal, pointer: coarse, hover: yes, overflow-block: scroll, overflow-inline: scroll
  1876 			<li>Chromebook pixel: update-frequency: normal, pointer: coarse *and* fine, hover: over, overflow-block: scroll, overflow-inline: scroll
  1877 			<li>Glass: update-frequency: normal, pointer: coarse, hover: none, overflow-block: none, overflow-inline: none
  1878 			<li>XTERM: update-frequency: normal, pointer:none, hover:none, grid:1, overflow-block: scroll, overflow-inline: none
  1880 		</ul>
  1881 	</div>
  1883 	<div class='issue'>
  1884 		<a href="http://lists.w3.org/Archives/Public/www-style/2013Mar/0448.html">http://lists.w3.org/Archives/Public/www-style/2013Mar/0448.html</a>
  1886 		MQ for detecting if the device is willing to display/print backgrounds and other ink-hungry properties.
  1887 	</div>
  1889 	<p class="issue">
  1890 		Another media feature should probably be added to deal with the type of resolution authors want to know to deal with monochrome printing.
  1891 -->
  1892 <!--
  1893  ██████  ██     ██  ██████  ████████  ███████  ██     ██       ██     ██  ███████
  1894 ██    ██ ██     ██ ██    ██    ██    ██     ██ ███   ███       ███   ███ ██     ██
  1895 ██       ██     ██ ██          ██    ██     ██ ████ ████       ████ ████ ██     ██
  1896 ██       ██     ██  ██████     ██    ██     ██ ██ ███ ██       ██ ███ ██ ██     ██
  1897 ██       ██     ██       ██    ██    ██     ██ ██     ██       ██     ██ ██  ██ ██
  1898 ██    ██ ██     ██ ██    ██    ██    ██     ██ ██     ██       ██     ██ ██    ██
  1899  ██████   ███████   ██████     ██     ███████  ██     ██       ██     ██  █████ ██
  1900 -->
  1902 <h2 id='custom-mq'>
  1903 Custom Media Queries</h2>
  1905 	When designing documents that use media queries,
  1906 	the same media query may be used in multiple places,
  1907 	such as to qualify multiple ''@import'' statements.
  1908 	Repeating the same media query multiple times is an editing hazard;
  1909 	an author making a change must edit every copy in the same way,
  1910 	or suffer from difficult-to-find bugs in their CSS.
  1912 	To help ameliorate this,
  1913 	this specification defines a method of defining <a>custom media queries</a>,
  1914 	which are simply-named aliases for longer and more complex media queries.
  1915 	In this way, a media query used in multiple places can instead be assigned to a <a>custom media query</a>,
  1916 	which can be used everywhere,
  1917 	and editing the media query requires touching only one line of code.
  1919 	A <dfn>custom media query</dfn> is defined with the ''@custom-media'' rule:
  1921 	<pre class='prod'>
  1922 		<dfn>@custom-media</dfn> = @custom-media <<extension-name>> [ <<media-query-list>> | true | false ] ;
  1923 	</pre>
  1925 	The <<extension-name>> can then be used in a <a>media feature</a>.
  1926 	It <strong>must</strong> be used in a <a>boolean context</a>;
  1927 	using them in a normal or <a>range context</a> is a syntax error.
  1928 	If a <<media-query-list>> is given,
  1929 	the <a>custom media query</a> evaluates to true
  1930 	if the <<media-query-list>> it represents evaluates to true,
  1931 	and false otherwise.
  1932 	If <dfn value for="@custom-media">true</dfn> or <dfn value for="@custom-media">false</dfn> is given,
  1933 	the <a>custom media query</a> evaluates to true or false, respectively.
  1935 	A ''@custom-media'' rule can refer to other <a>custom media queries</a>.
  1936 	However, loops are forbidden,
  1937 	and a <a>custom media query</a> must not be defined in terms of itself or
  1938 	of another <a>custom media query</a> that directly or indirectly refers to it.
  1939 	Any such attempt of defining a <a>custom media query</a> with a circular dependency
  1940 	must cause all the <a>custom media queries</a> in the loop to fail to be defined.
  1942 	Note: For error handling purposes,
  1943 	an undefined <a>media feature</a> is different from
  1944 	a <a>media feature</a> that evaluates to false.
  1945 	See <a href="#error-handling">Error Handling</a> for details.
  1947 	<div class='example'>
  1948 		For example, if a responsive site uses a particular breakpoint in several places,
  1949 		it can alias that with a reasonable name:
  1951 		<pre>
  1952 			@custom-media --narrow-window (max-width: 30em);
  1954 			@media (--narrow-window) {
  1955 				/* narrow window styles */
  1957 			@media (--narrow-window) and (script) {
  1958 				/* special styles for when script is allowed */
  1960 			/* etc */
  1961 		</pre>
  1962 	</div>
  1964 <h3 id='script-custom-mq'>
  1965 Script-based Custom Media Queries</h3>
  1967 	<div class='issue'>
  1968 		Define a map of names to values for JS.
  1969 		Values can be either a MediaQueryList object or a boolean,
  1970 		in which case it's treated identically to the above,
  1971 		or can be a number or a string,
  1972 		in which case it's treated like a normal MQ,
  1973 		and can use the normal or range context syntax.
  1974 		Like:
  1976 		<pre>
  1977 			&lt;script>
  1978 			CSS.customMedia.set('--foo', 5);
  1979 			&lt;/script>
  1980 			&lt;style>
  1981 			@media (_foo: 5) { ... }
  1982 			@media (_foo < 10) { ... }
  1983 			&lt;/style>
  1984 		</pre>
  1985 	</div>
  1987 <!--
  1988  ██████   ██████   ██████   ███████  ██     ██
  1989 ██    ██ ██    ██ ██    ██ ██     ██ ███   ███
  1990 ██       ██       ██       ██     ██ ████ ████
  1991 ██        ██████   ██████  ██     ██ ██ ███ ██
  1992 ██             ██       ██ ██     ██ ██     ██
  1993 ██    ██ ██    ██ ██    ██ ██     ██ ██     ██
  1994  ██████   ██████   ██████   ███████  ██     ██
  1995 -->
  1997 <h3 id='custom-mq-cssom'>
  1998 CSSOM</h3>
  2000 	The <a interface>CSSRule</a> interface is extended as follows:
  2002 	<pre class="idl partial">
  2003 	partial interface CSSRule {
  2004 		const unsigned short CUSTOM_MEDIA_RULE = 17;
  2005 	};
  2006 	</pre>
  2008 	The <a interface>CSSCustomMediaRule</a> interface represents a ''@custom-media'' rule.
  2010 	<pre class="idl">
  2011 	interface CSSCustomMediaRule : CSSRule {
  2012 		attribute DOMString name;
  2013 		[SameObject, PutForwards=mediaText] readonly attribute MediaList media;
  2014 	};
  2015 	</pre>
  2017 	<dl dfn-type=attribute dfn-for=CSSCustomMediaRule>
  2018 		<dt><dfn>name</dfn>, of type <code>DOMString</code>
  2019 		<dd>
  2020 			The <a attribute>name</a> attribute on getting must return a <code>DOMString</code> object
  2021 			that contains the serialization of the <<extension-name>> defined for the associated rule.
  2023 			On setting the <a attribute>name</a> attribute,
  2024 			run the following steps:
  2026 			<ol>
  2027 				<li><a>Parse a component value</a> from the value.
  2029 				<li>
  2030 					If the returned value is an <<extension-name>>,
  2031 					replace the associated rule's name with the <<extension-name>>'s representation.
  2033 				<li>
  2034 					Otherwise, do nothing.
  2035 			</ol>
  2037 		<dt><dfn>media</dfn>, of type <a interface>MediaList</a>, readonly
  2038 		<dd>
  2039 			The <a attribute>media</a> attribute must return a <a interface>MediaList</a> object
  2040 			for the <<media-query-list>> specified with the associated rule.
  2041 	</dl>
  2043 <!--
  2044 ████████  ████████ ████████  ████████  ████████  ██████     ███    ████████ ████████ ████████        ████████ ████████    ███    ████████ ██     ██ ████████  ████████  ██████
  2045 ██     ██ ██       ██     ██ ██     ██ ██       ██    ██   ██ ██      ██    ██       ██     ██       ██       ██         ██ ██      ██    ██     ██ ██     ██ ██       ██    ██
  2046 ██     ██ ██       ██     ██ ██     ██ ██       ██        ██   ██     ██    ██       ██     ██       ██       ██        ██   ██     ██    ██     ██ ██     ██ ██       ██
  2047 ██     ██ ██████   ████████  ████████  ██████   ██       ██     ██    ██    ██████   ██     ██       ██████   ██████   ██     ██    ██    ██     ██ ████████  ██████    ██████
  2048 ██     ██ ██       ██        ██   ██   ██       ██       █████████    ██    ██       ██     ██       ██       ██       █████████    ██    ██     ██ ██   ██   ██             ██
  2049 ██     ██ ██       ██        ██    ██  ██       ██    ██ ██     ██    ██    ██       ██     ██       ██       ██       ██     ██    ██    ██     ██ ██    ██  ██       ██    ██
  2050 ████████  ████████ ██        ██     ██ ████████  ██████  ██     ██    ██    ████████ ████████        ██       ████████ ██     ██    ██     ███████  ██     ██ ████████  ██████
  2051 -->
  2053 <h2 id='mf-deprecated'>
  2054 Appendix A: Deprecated Media Features</h2>
  2056 	<p>The following <a>media features</a> are <strong>deprecated</strong>. They
  2057 	kept for backward compatibility, but are not appropriate for newly
  2058 	written style sheets. Authors must not use them. User agents must support them
  2059 	as specified.
  2061 	<p class="note">To query for the size of the viewport (or the page box
  2062 	on page media), the 'width', 'height' and 'aspect-ratio' <a>media features</a>
  2063 	should be used, rather than 'device-width', 'device-height' and
  2064 	'device-aspect-ratio', which refer to the physical size of the the device
  2065 	regardless of how much space is available for the document being laid out. The
  2066 	device-* <a>media features</a> are also sometimes used as a proxy to detect
  2067 	mobile devices. Instead, authors should use <a>media features</a> that better
  2068 	represent the aspect of the device that they are attempting to style against.
  2070 <h3 id="device-width" class="no-toc no-num">
  2071 device-width</h3>
  2073 	<pre class='descdef mq'>
  2074 	Name: device-width
  2075 	Value: <<length>>
  2076 	For: @media
  2077 	Type: range
  2078 	</pre>
  2080 	The 'device-width' media feature describes the width of the rendering surface of the output device.
  2081 	For continuous media, this is the width of the screen.
  2082 	For paged media, this is the width of the page sheet size.
  2084 	A specified <<length>> cannot be negative.
  2086 	<div class="example">
  2087 		<pre>@media (device-width < 800px) { … }</pre>
  2089 		In the example above, the style sheet will apply only to screens
  2090 		less than ''800px'' in length.
  2091 		The ''px'' unit is of the logical kind,
  2092 		as described in the <a href="#units">Units</a> section.
  2093 	</div>
  2095 	Note: If a device can be used in multiple orientations,
  2096 	such as portrait and landscape,
  2097 	the 'device-*' media features reflect the current orientation.
  2099 <h3 id="device-height" class="no-toc no-num">
  2100 device-height</h3>
  2102 	<pre class='descdef mq'>
  2103 	Name: device-height
  2104 	Value: <<length>>
  2105 	For: @media
  2106 	Type: range
  2107 	</pre>
  2109 	The 'device-height' media feature describes the height of the rendering surface of the output device.
  2110 	For continuous media, this is the height of the screen.
  2111 	For paged media, this is the height of the page sheet size.
  2113 	A specified &lt;length> cannot be negative.
  2115 	<div class="example">
  2116 		<pre>&lt;link rel="stylesheet" media="(device-height > 600px)" /&gt;</pre>
  2118 		In the example above, the style sheet will apply only to screens
  2119 		taller than 600 vertical pixels.
  2120 		Note that the definition of the ''px'' unit is the same as in other parts of CSS.
  2121 	</div>
  2124 <h3 id='device-aspect-ratio' class="no-toc no-num">
  2125 device-aspect-ratio</h3>
  2127 	<pre class='descdef mq'>
  2128 	Name: device-aspect-ratio
  2129 	Value: <<ratio>>
  2130 	For: @media
  2131 	Type: range
  2132 	</pre>
  2134 	The 'device-aspect-ratio media feature is defined as the ratio of
  2135 	the value of the 'device-width' media feature to
  2136 	the value of the 'device-height media feature.
  2138 	<div class="example">
  2139 		For example, if a screen device with square pixels
  2140 		has 1280 horizontal pixels and 720 vertical pixels
  2141 		(commonly referred to as "16:9"),
  2142 		the following media queries will all match the device:
  2144 		<pre>
  2145 		@media (device-aspect-ratio: 16/9) { … }
  2146 		@media (device-aspect-ratio: 32/18) { … }
  2147 		@media (device-aspect-ratio: 1280/720) { … }
  2148 		@media (device-aspect-ratio: 2560/1440) { … }
  2149 		</pre>
  2150 	</div>
  2153 <h2 id="changes" class="no-num">
  2154 Changes</h2>
  2155 <h3 id="changes-2012">
  2156 Changes Since the Media Queries Level 3</h3>
  2158 The following changes were made to this specification since the
  2159 <a href="http://www.w3.org/TR/css3-mediaqueries/">19 June 2012 Recomendation of Media Queries Level 3</a>:
  2161 <ul>
  2162 	<li>
  2163 		Large editorial rewrite and reorgization of the document.
  2165 	<li>
  2166 		<a href="#mq-boolean-context">Boolean-context</a> <a>media features</a> are now additionally false
  2167 		if they would be true for the keyword ''none''.
  2169 	<li>
  2170 		<a>Media features</a> with numeric values can now be written in a <a href="#mq-range-context">range context</a>.
  2172 	<li>
  2173 		The 'scripting', 'pointer', 'hover', 'light-level', 'update-frequency', 'overflow-block', and 'overflow-inline' media features were added.
  2175 	<li>
  2176 		''or'', ''and'', ''only'' and ''not'' are disallowed from being recognized as media types,
  2177 		even invalid ones.
  2178 		(They'll trigger a syntax error instead.)
  2180 	<li>
  2181 		White space is required around the keyword “and” as well as after “not” and “only”.
  2183 	<li>
  2184 		All media types except for ''screen'', ''print'', ''speech'', and ''all'' are deprecated.
  2186 	<li>
  2187 		Deprecated 'device-width', 'device-height', 'device-aspect-ratio'
  2188 </ul>
  2191 <h2 class="no-num" id="acknowledgments">
  2192 Acknowledgments</h2>
  2194 This specification is the product of the W3C Working Group on
  2195 Cascading Style Sheets.
  2197 Comments from
  2198  Arve Bersvendsen,
  2199  Björn Höhrmann,
  2200  Chris Lilley,
  2201  Christoph Päper,
  2202  L. David Baron,
  2203  Elika J. Etemad,
  2204  François Remy,
  2205  Melinda Grant,
  2206  Nicholas C. Zakas
  2207  Philipp Hoschka,
  2208  Rick Byers,
  2209  Rijk van Geijtenbeek,
  2210  Roger Gimson,
  2211  Sigurd Lerstad,
  2212  Simon Kissane,
  2213  Simon Pieters,
  2214  Steven Pemberton,
  2215  and Susan Lesch
  2216 improved this specification.

mercurial