-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathdeferred-for-level-5.txt
More file actions
238 lines (193 loc) · 8.77 KB
/
deferred-for-level-5.txt
File metadata and controls
238 lines (193 loc) · 8.77 KB
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
<!--
████████ ██ ██ ██ ██
██ ███ ██ ██ ██
██ ████ ██ ██ ██
██████ ██ ██ ██ ██ ██
██ ██ ████ ██ ██
██ ██ ███ ██ ██
████████ ██ ██ ███
-->
<h2 id='mf-environment'>
Environment Media Features</h2>
<h3 id="light-level">
light-level</h3>
<pre class='descdef mq'>
Name: light-level
Value: dim | normal | washed
For: @media
Type: discrete
</pre>
The 'light-level' media feature is used to query about the ambient light-level in which the device is used,
to allow the author to adjust style of the document in response.
The following values are valid:
<dl dfn-type=value dfn-for="@media/light-level">
<dt><dfn>dim</dfn>
<dd>
The device is used in a dim environment,
where excessive contrast and brightness would be distracting or uncomfortable to the reader.
For example: night time, or a dimly illuminated indoor environment.
<dt><dfn>normal</dfn>
<dd>
The device is used in a environment with a light level in the ideal range for the screen,
and which does not necessitate any particular adjustment.
<dt><dfn>washed</dfn>
<dd>
The device is used in an exceptionally bright environment,
causing the screen to be washed out and difficult to read.
For example: bright daylight.
</dl>
User agents should set the thresholds between the three levels
in a way that takes into account the characteristics of the device.
<div class="note">
Even though it is expected that User Agents will adjust the value of this media feature
based on ambient light sensors,
this specification intentionally refrains from defining the three levels in terms of a measurement in lux,
for several reasons:
<ul>
<li>
Devices equipped with a light sensor usually adjust the brightness of the screen automatically.
Depending on the level of adjustment,
the thresholds for needing a low contrast or hight contrast content may vary.
<li>
Different screen technologies wash out at very different ambient light levels;
e-ink displays remain readable in bright daylight,
while liquid crystal displays do not.
<li>
Many embedded light sensors are inaccurately calibrated,
making it difficult to establish useful thresholds valid across devices.
</ul>
</div>
For accessibility purposes, user agents may offer manual controls
allowing the user to switch between the three levels of independently of the ambient light level,
as high contrast or low contrast styles may be more suitable for users with visual disabilities.
<p class="issue">
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>.
Can we adjust this so that it covers all use cases for both,
or somehow modify them to work in an orthogonal, rather than overlapping, fashion?
<div class="example">
<pre>
@media (light-level: normal) {
p { background: url("texture.jpg"); color: #333 }
}
@media (light-level: dim) {
p { background: #222; color: #ccc }
}
@media (light-level: washed) {
p { background: white; color: black; font-size: 2em; }
}
</pre>
</div>
<!--
██████ ██ ██ ██████ ████████ ███████ ██ ██ ██ ██ ███████
██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ███ ███ ███ ██ ██
██ ██ ██ ██ ██ ██ ██ ████ ████ ████ ████ ██ ██
██ ██ ██ ██████ ██ ██ ██ ██ ███ ██ ██ ███ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ███████ ██████ ██ ███████ ██ ██ ██ ██ █████ ██
-->
<h2 id='custom-mq'>
Custom Media Queries</h2>
When designing documents that use media queries,
the same media query may be used in multiple places,
such as to qualify multiple ''@import'' statements.
Repeating the same media query multiple times is an editing hazard;
an author making a change must edit every copy in the same way,
or suffer from difficult-to-find bugs in their CSS.
To help ameliorate this,
this specification defines a method of defining <a>custom media queries</a>,
which are simply-named aliases for longer and more complex media queries.
In this way, a media query used in multiple places can instead be assigned to a <a>custom media query</a>,
which can be used everywhere,
and editing the media query requires touching only one line of code.
A <dfn>custom media query</dfn> is defined with the ''@custom-media'' rule:
<pre class='prod'>
<dfn>@custom-media</dfn> = @custom-media <<extension-name>> [ <<media-query-list>> | true | false ] ;
</pre>
The <<extension-name>> can then be used in a <a>media feature</a>.
It <strong>must</strong> be used in a <a>boolean context</a>;
using them in a normal or <a>range context</a> is a syntax error.
If a <<media-query-list>> is given,
the <a>custom media query</a> evaluates to true
if the <<media-query-list>> it represents evaluates to true,
and false otherwise.
If <dfn value for="@custom-media">true</dfn> or <dfn value for="@custom-media">false</dfn> is given,
the <a>custom media query</a> evaluates to true or false, respectively.
A ''@custom-media'' rule can refer to other <a>custom media queries</a>.
However, loops are forbidden,
and a <a>custom media query</a> must not be defined in terms of itself or
of another <a>custom media query</a> that directly or indirectly refers to it.
Any such attempt of defining a <a>custom media query</a> with a circular dependency
must cause all the <a>custom media queries</a> in the loop to fail to be defined.
Note: For error handling purposes,
an undefined <a>media feature</a> is different from
a <a>media feature</a> that evaluates to false.
See <a href="#error-handling">Error Handling</a> for details.
<div class='example'>
For example, if a responsive site uses a particular breakpoint in several places,
it can alias that with a reasonable name:
<pre>
@custom-media --narrow-window (max-width: 30em);
@media (--narrow-window) {
/* narrow window styles */
}
@media (--narrow-window) and (script) {
/* special styles for when script is allowed */
}
/* etc */
</pre>
</div>
<h3 id='script-custom-mq'>
Script-based Custom Media Queries</h3>
<div class='issue'>
Define a map of names to values for JS.
Values can be either a MediaQueryList object or a boolean,
in which case it's treated identically to the above,
or can be a number or a string,
in which case it's treated like a normal MQ,
and can use the normal or range context syntax.
Like:
<pre>
<script>
CSS.customMedia.set('--foo', 5);
</script>
<style>
@media (_foo: 5) { ... }
@media (_foo < 10) { ... }
</style>
</pre>
</div>
<h3 id="inverted">
inverted-colors</h3>
<pre class='descdef mq'>
Name: inverted-colors
Value: none | inverted
For: @media
Type: discrete
</pre>
The 'inverted-colors' media feature indicates whether the content is displayed normally, or whether colors have been inverted.
Note: This is an indication that the user agent or underlying
operating system has forcibly inverted all colors, not a request to do so. This
is sometimes provided as a simple accessibility feature, allowing users to
switch between light-on-dark and dark-on-light text. However, this has
unpleasant side effects, such as inverting pictures, or turning shadows into
highlights, which reduce the readability of the content.
<dl dfn-type=value dfn-for="@media/inverted-colors">
<dt><dfn>none</dfn>
<dd>
Colors are displayed normally.
<dt><dfn>inverted</dfn>
<dd>
All pixels within the displayed area have been inverted.
</dl>
<div class="example">
For example, a user frequently using their operating system's ability to invert the screens color
may want to add the following to their user style sheet,
to limit the undesirable side effects of the inversion.
<pre>
@media (inverted-colors) {
img { filter: invert(100%); }
* { text-shadow: none; box-shadow: none; }
}
</pre>
</div>