Skip to content

Commit ca6e21b

Browse files
"Meta viewport allows for zoom" (b4f0c3): Explicit meaning of 'has' (#1994)
* Explicit meaning of 'has' * Improve expectation and examples * Typo * Improve algorithm description Co-authored-by: Carlos Duarte <caduarte@campus.ul.pt> * Rephrase expectations * Streamline Applicability * Typo * Simplify expectations --------- Co-authored-by: Carlos Duarte <caduarte@campus.ul.pt>
1 parent cd5bde3 commit ca6e21b

1 file changed

Lines changed: 128 additions & 18 deletions

File tree

_rules/meta-viewport-b4f0c3.md

Lines changed: 128 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ input_aspects:
1616
- DOM Tree
1717
acknowledgments:
1818
authors:
19+
- Jean-Yves Moyen
20+
previous_authors:
1921
- Audrey Maniez
2022
- Jey Nandakumar
2123
funding:
@@ -24,22 +26,37 @@ acknowledgments:
2426

2527
## Applicability
2628

27-
This rule applies to each `content` attribute on a `meta` element with a `name` [attribute value][] of `viewport` for which at least one of the following is true:
29+
This rule applies to each `content` attribute for which all of the following are true:
2830

29-
- the `content` [attribute value][] has the `user-scalable` property; or
30-
- the `content` [attribute value][] has the `maximum-scale` property.
31+
- the attribute is defined on a `meta` element with a `name` [attribute value][] of `viewport`; and
32+
- the [attribute value][] has at least one of the `maximum-scale` or `user-scalable` keys.
33+
34+
For the purpose of this rule, the [attribute value][] of the `content` attribute is a list of key/value pairs.
3135

3236
## Expectation 1
3337

34-
For each test target, the [attribute value][] does not have a `user-scalable` property with a value of `no`.
38+
For each test target's [attribute value][], at least one of the following is true:
39+
40+
- `user-scalable` is not defined; or
41+
- `user-scalable` is `yes`, `device-width` or `device-height`; or
42+
- `user-scalable` is a number which is not between -1 and 1 (excluded).
43+
44+
**Note:** This is equivalent to applying the [translations into a `@viewport` descriptors][descriptor translation] and not obtaining a value of `fixed` for the `user-zoom` descriptor from [the translation for `user-scalable`](https://www.w3.org/TR/css-device-adapt-1/#user-scalable).
3545

3646
## Expectation 2
3747

38-
For each test target, the [attribute value][] does not have a `maximum-scale` property with a value less than 2.
48+
For each test target's [attribute value][], at least one of the following is true:
49+
50+
- `maximum-scale` is not defined; or
51+
- `maximum-scale` is `device-width` or `device-height`; or
52+
- `maximum-scale` is a negative number; or
53+
- `maximum-scale` is a number which is 2 or more.
54+
55+
**Note:** This is equivalent to applying the [translations into a `@viewport` descriptors][descriptor translation] and not obtaining a value smaller than 2 for the `max-zoom` descriptor from [the translation for `maximum-scale`](https://www.w3.org/TR/css-device-adapt-1/#min-scale-max-scale).
3956

4057
## Assumptions
4158

42-
Pages for which any of the following is true may satisfy success criteria Success Criteria [1.4.4 Resize text][sc144] and [1.4.10 Reflow][sc1410], even if the rule results in a failed outcome.
59+
Pages for which any of the following is true may satisfy Success Criteria [1.4.4 Resize text][sc144] and [1.4.10 Reflow][sc1410], even if the rule results in a failed outcome.
4360

4461
- The [page][] has no [visible][] [content][]; or
4562
- There is another [mechanism](https://www.w3.org/TR/WCAG21/#dfn-mechanism) available to resize the text content; or
@@ -49,6 +66,8 @@ Pages for which any of the following is true may satisfy success criteria Succes
4966

5067
Desktop browsers ignore the viewport `meta` element, and most modern mobile browsers either ignore it by default or have an accessibility option which will allow zooming. This rule is not relevant for desktop browsers, nor for most modern mobile browsers. Only users with older mobile browsers can experience issues tested by this rule.
5168

69+
The exact way the `content` attribute should be parsed (notably, for error handling) is not fully specified. CSS specification includes a [non-normative parsing algorithm](https://www.w3.org/TR/css-device-adapt-1/#parsing-algorithm). Different user agents may behave differently in some cases.
70+
5271
## Background
5372

5473
### Bibliography
@@ -83,6 +102,24 @@ This viewport `meta` element does not prevent user scaling because it has `user-
83102

84103
#### Passed Example 2
85104

105+
This viewport `meta` element does not prevent user scaling because it has `user-scalable` set to `5`.
106+
107+
```html
108+
<html>
109+
<head>
110+
<title>Simple page showing random text</title>
111+
<meta name="viewport" content="user-scalable=5" />
112+
</head>
113+
<body>
114+
<p>
115+
Lorem ipsum
116+
</p>
117+
</body>
118+
</html>
119+
```
120+
121+
#### Passed Example 3
122+
86123
This viewport `meta` element allows users to scale content up to 200% because it has `maximum-scale` set to 2.0.
87124

88125
```html
@@ -99,9 +136,9 @@ This viewport `meta` element allows users to scale content up to 200% because it
99136
</html>
100137
```
101138

102-
#### Passed Example 3
139+
#### Passed Example 4
103140

104-
This viewport `meta` element does not prevent user scaling because it has `maximum-scale` set to -1 which results in this value being dropped.
141+
This viewport `meta` element does not prevent user scaling because it has `maximum-scale` set to -1, a negative value.
105142

106143
```html
107144
<html>
@@ -117,6 +154,24 @@ This viewport `meta` element does not prevent user scaling because it has `maxim
117154
</html>
118155
```
119156

157+
#### Passed Example 5
158+
159+
This viewport `meta` element does not prevent user scaling because it has `maximum-scale` set to `device-width`.
160+
161+
```html
162+
<html>
163+
<head>
164+
<title>Simple page showing random text</title>
165+
<meta name="viewport" content="maximum-scale=device-width" />
166+
</head>
167+
<body>
168+
<p>
169+
Lorem ipsum
170+
</p>
171+
</body>
172+
</html>
173+
```
174+
120175
### Failed
121176

122177
#### Failed Example 1
@@ -139,13 +194,13 @@ This viewport `meta` element prevents user scaling because it has `user-scalable
139194

140195
#### Failed Example 2
141196

142-
This viewport `meta` element prevents users to scale content up to 200% because it has `maximum-scale` set to 1.5.
197+
This viewport `meta` element prevents user scaling because it has `user-scalable` set to `0.5`.
143198

144199
```html
145200
<html>
146201
<head>
147202
<title>Simple page showing random text</title>
148-
<meta name="viewport" content="user-scalable=yes, initial-scale=0.8, maximum-scale=1.5" />
203+
<meta name="viewport" content="user-scalable=0.5" />
149204
</head>
150205
<body>
151206
<p>
@@ -157,13 +212,13 @@ This viewport `meta` element prevents users to scale content up to 200% because
157212

158213
#### Failed Example 3
159214

160-
This viewport `meta` element prevents users to scale content up to 200% because it has `maximum-scale` set to 1.0.
215+
This viewport `meta` element prevents user scaling because it has `user-scalable` set to `invalid`.
161216

162217
```html
163218
<html>
164219
<head>
165220
<title>Simple page showing random text</title>
166-
<meta name="viewport" content="maximum-scale=1.0" />
221+
<meta name="viewport" content="user-scalable=invalid" />
167222
</head>
168223
<body>
169224
<p>
@@ -175,7 +230,25 @@ This viewport `meta` element prevents users to scale content up to 200% because
175230

176231
#### Failed Example 4
177232

178-
This viewport `meta` element prevents users to scale content up to 200% because it has `maximum-scale` set to `yes` which translates to 1.0.
233+
This viewport `meta` element prevents users to scale content up to 200% because it has `maximum-scale` set to 1.5.
234+
235+
```html
236+
<html>
237+
<head>
238+
<title>Simple page showing random text</title>
239+
<meta name="viewport" content="user-scalable=yes, initial-scale=0.8, maximum-scale=1.5" />
240+
</head>
241+
<body>
242+
<p>
243+
Lorem ipsum
244+
</p>
245+
</body>
246+
</html>
247+
```
248+
249+
#### Failed Example 5
250+
251+
This viewport `meta` element prevents users to scale content up to 200% because it has `maximum-scale` set to `yes`.
179252

180253
```html
181254
<html>
@@ -191,6 +264,42 @@ This viewport `meta` element prevents users to scale content up to 200% because
191264
</html>
192265
```
193266

267+
#### Failed Example 6
268+
269+
This viewport `meta` element prevents users to scale content up to 200% because it has `maximum-scale` set to `yes`.
270+
271+
```html
272+
<html>
273+
<head>
274+
<title>Simple page showing random text</title>
275+
<meta name="viewport" content="maximum-scale=yes" />
276+
</head>
277+
<body>
278+
<p>
279+
Lorem ipsum
280+
</p>
281+
</body>
282+
</html>
283+
```
284+
285+
#### Failed Example 7
286+
287+
This viewport `meta` element prevents users to scale content up to 200% because it has `maximum-scale` set to `invalid`.
288+
289+
```html
290+
<html>
291+
<head>
292+
<title>Simple page showing random text</title>
293+
<meta name="viewport" content="maximum-scale=invalid" />
294+
</head>
295+
<body>
296+
<p>
297+
Lorem ipsum
298+
</p>
299+
</body>
300+
</html>
301+
```
302+
194303
### Inapplicable
195304

196305
#### Inapplicable Example 1
@@ -265,13 +374,14 @@ This viewport `meta` element does not prevent user scaling because it does not s
265374
</html>
266375
```
267376

377+
[attribute value]: #attribute-value 'Definition of attribute value'
268378
[content]: https://www.w3.org/TR/WCAG21/#dfn-content 'content (Web content)'
269-
[maximum-scale]: https://www.w3.org/TR/css-device-adapt-1/#min-scale-max-scale 'The initial-scale, minimum-scale, and maximum-scale properties'
379+
[css pixels]: https://www.w3.org/TR/css3-values/#reference-pixel 'CSS 3 definition, reference pixel'
380+
[descriptor translation]: https://www.w3.org/TR/css-device-adapt-1/#translate-meta-to-at-viewport 'Translations of the content attribute into @viewport descriptors'
270381
[meta]: https://html.spec.whatwg.org/#the-meta-element 'The meta element'
382+
[maximum-scale]: https://www.w3.org/TR/css-device-adapt-1/#min-scale-max-scale 'The initial-scale, minimum-scale, and maximum-scale properties'
271383
[page]: https://www.w3.org/TR/WCAG21/#dfn-web-page-s 'Web page'
272-
[user-scalable]: https://www.w3.org/TR/css-device-adapt-1/#user-scalable 'The user-scalable property'
273-
[attribute value]: #attribute-value 'Definition of attribute value'
274-
[visible]: #visible 'Definition of visible'
275-
[css pixels]: https://www.w3.org/TR/css3-values/#reference-pixel 'CSS 3 definition, reference pixel'
276384
[sc144]: https://www.w3.org/TR/WCAG21/#resize-text 'WCAG 2.1 Success Criterion 1.4.4 Resize text'
277385
[sc1410]: https://www.w3.org/TR/WCAG21/#reflow 'WCAG 2.1 Success Criterion 1.4.10 Reflow'
386+
[user-scalable]: https://www.w3.org/TR/css-device-adapt-1/#user-scalable 'The user-scalable property'
387+
[visible]: #visible 'Definition of visible'

0 commit comments

Comments
 (0)