/
index.html
316 lines (307 loc) · 11.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title>length-property: length \9; hack – CSS Hacks Lab</title>
<link href="../../microstrap.css" rel="stylesheet" />
<style>
.testbed {
height: 100px;
width: 100px;
line-height: 100px;/* vertical centering trick */
white-space: nowrap;
font-family: Helvetica,Arial,sans-serif;
font-weight: bold;
font-size: large;
position: relative;/* to make abspos child work properly; blame CSS logic */
}
.testbed-margin {
overflow: hidden;
}
.liquid {
height: 100%;
width: 100%;
}
.guineapig {
position: absolute;
top: 0;
left: 0;
}
.guineapig-padding {
width: 0;
height: 0;
}
.guineapig-wh {
width: 0px;
height: 0px;
overflow: hidden;
}
.guineapig-margin {
position: absolute;
left: 100px;
}
.guineapig-border-width {
width: 0;
height: 0;
border-style: solid;
border-color: limegreen;
border-width: 0;
}
</style>
<!-- Operative part of the test: -->
<style>
.guineapig-padding {
padding-right: 100px \9;
padding-bottom: 100px \9;
}
</style>
<style>
.guineapig-wh {
width: 100px \9;
height: 100px \9;
}
</style>
<style>
.guineapig-margin {
margin-left: -100px \9;
}
</style>
<style>
.guineapig-border-width {
border-right-width: 100px \9;
border-bottom-width: 100px \9;
}
</style>
</head>
<body>
<div class="container">
<h1>The <code>length-property: length \9;</code> hack</h1>
<p>Last updated 2016-02-03.</p>
<h2>The hack</h2>
<div class="scroll-x">
<pre>
.your-selector-here {
some-length-property-here: somelength \9;
}
</pre>
</div>
<p>…where <code>somelength</code> is a <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/length">CSS length value</a> and <code>some-length-property-here</code> is a CSS property whose value can be a CSS length.</p>
<!--
FIXME: WHAT ABOUT PERCENT LENGTHS?
-->
<p>
Source: <a href="http://www.paulirish.com/2009/browser-specific-css-hacks/">Browser CSS Hacks</a> by Paul Irish
</p>
<p>
<strong>Important note!</strong>
This article <strong>only</strong> applies to the specific properties mentioned below and <strong>only</strong> applies when there is space between <code>somelength</code> and <code>\9</code>.
Adding spaces or using different properties <em>may change the compatibility of the hack</em>.<br />
You have been warned.
</p>
<h2 id="tests">Live testcases</h2>
<div class="testbed text-center">
<div class="yes guineapig guineapig-wh">Affected</div>
<div class="no">Unaffected</div>
</div>
<p>If the square above shows the word "Affected", then your browser supports this hack for the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/width"><code>width</code></a> and <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/height"><code>height</code></a> CSS properties.</p>
<div class="testbed testbed-margin text-center">
<div class="guineapig-margin liquid yes">Affected</div>
<div class="liquid no">Unaffected</div>
</div>
<p>If the square above shows the word "Affected", then your browser supports this hack for the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/margin"><code>margin-{top,bottom,left,right}</code></a> CSS properties.</p>
<div class="testbed no">
<div class="guineapig-padding yes"></div>
</div>
<p>If the above square is light green, then your browser supports this hack for the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/padding"><code>padding-{top,bottom,left,right}</code></a> CSS properties.</p>
<div class="testbed no">
<div class="guineapig-border-width"></div>
</div>
<p>If the above square is light green, then your browser supports this hack for the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/margin"><code>border-{top,bottom,left,right}-width</code></a> CSS properties.</p>
<h2 id="how-it-works">How it works</h2>
<p><a href="https://drafts.csswg.org/css-syntax/#escaping">Backslash (<code>\</code>) is used as an escape character in CSS.</a> So <code>\9</code> is an escape sequence which encodes the <a href="https://en.wikipedia.org/wiki/Tab_character">tab character (U+0009).</a> Presumably the affected browsers are interpreting it like a literal tab character and thus ignoring it when parsing <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/length">length values</a>, since whitespace between the value and the semicolon that ends a declaration doesn't matter in CSS (something like <code>width: 5px ;</code> is perfectly valid). The space before the <code>\9</code> doesn't appear to affect its compatibility. IE8-10 are known to suffer from the bug that this hack relies upon.</p>
<h2 id="compat">Affected browsers</h2>
<p>Check out the links for corroborating screenshots.</p>
<div class="scroll-x">
<table class="table table-bordered">
<caption>Test results</caption>
<thead class="thead-browsers">
<tr>
<th>
<img src="../../browser-imgs/chrome_64x64.png" alt="Chrome" /><br />
</th>
<th>
<img src="../../browser-imgs/safari-osx_64x64.png" alt="OS X Safari" /><br />
</th>
<th>
<img src="../../browser-imgs/safari-ios_64x64.png" alt="iOS Safari" /><br />
</th>
<th>
<img src="../../browser-imgs/firefox_64x64.png" alt="Firefox" /><br />
</th>
<th>
<img src="../../browser-imgs/edge_64x64.png" alt="Microsoft Edge" /><br />
</th>
<th>
<img src="../../browser-imgs/ie_64x64.png" alt="Internet Explorer" /><br />
</th>
</tr>
<tr>
<th>Chrome</th>
<th>OS X<br />Safari</th>
<th>iOS<br />Safari</th>
<th>Firefox</th>
<th>MS Edge<a href="#edgenote"><sup>1</sup></a></th>
<th>Internet<br />Explorer</th>
</tr>
</thead>
<tbody>
<tr>
<td class="unknown">
49
<br />Unknown
</td>
<td class="unknown">
10
<br />Unknown
</td>
<td class="unknown">
9.3
<br />Unknown
</td>
<td class="unknown">
45
<br />Unknown
</td>
<td class="unknown">
13
<br />Unknown
</td>
<td class="empty"></td>
</tr>
<tr>
<td class="no">
48
<br /><a href="chrome/v48.png">Unaffected</a>
</td>
<td class="no">
9.0.3
<br /><a href="safari-osx/v9-0-3.png">Unaffected</a>
</td>
<td class="no">
9.2
<br /><a href="safari-ios/v9-2.png">Unaffected</a>
</td>
<td class="no">
44.0
<br /><a href="firefox/v44-0.png">Unaffected</a>
</td>
<td class="no">
12.10240
<br /><a href="edge/v12-10240.png">Unaffected</a>
</td>
<td class="no">
11
<br /><a href="ie/v11.png">Unaffected</a>
</td>
</tr>
<tr>
<td class="no">
47
<br /><a href="chrome/v47.png">Unaffected</a>
</td>
<td class="no">
8.0.8
<br /><a href="safari-osx/v8-0-8.png">Unaffected</a>
</td>
<td class="no">
8.4
<br /><a href="safari-ios/v8-4.png">Unaffected</a>
</td>
<td class="no">
43.0.1
<br /><a href="firefox/v43-0-1.png">Unaffected</a>
</td>
<td class="unknown">
12.10166
<br />Unknown
</td>
<td class="yes">
10
<br /><a href="ie/v10.png">Affected</a>
</td>
</tr>
<tr>
<td class="no">
26
<br /><a href="chrome/v26.png">Unaffected</a>
</td>
<td class="no">
7.1.7
<br /><a href="safari-osx/v7-1-7.png">Unaffected</a>
</td>
<td class="no">
7.1
<br /><a href="safari-ios/v7-1.png">Unaffected</a>
</td>
<td class="no">
4.0.1
<br /><a href="firefox/v4-0-1.png">Unaffected</a>
</td>
<td class="empty"></td>
<td class="yes">
9
<br /><a href="ie/v9.png">Affected</a>
</td>
</tr>
<tr>
<td class="unknown">
25
<br />Unknown
</td>
<td class="unknown">
6.2.7
<br />Unknown
</td>
<td class="unknown">
6.1
<br />Unknown
</td>
<td class="empty"></td>
<td class="empty"></td>
<td class="yes">
8
<br /><a href="ie/v8.png">Affected</a>
</td>
</tr>
<tr>
<td class="empty"></td>
<td class="empty"></td>
<td class="empty"></td>
<td class="empty"></td>
<td class="empty"></td>
<td class="unknown">
7
<br />Unknown
</td>
</tr>
</tbody>
</table>
</div>
<small class="note" id="edgenote">Note 1: MS Edge versions refer to the EdgeHTML rendering engine version, not the Edge app version shown in Edge's "About" screen. <a href="https://github.com/Fyrd/caniuse/issues/1928">See this <em>Can I Use</em> issue.</a></small><br />
<footer class="text-center">
<a href="http://browser-bugs.github.io/css-hacks/">CSS Hacks Lab</a> ·
<a href="https://github.com/browser-bugs/css-hacks">Contribute via GitHub</a> ·
<a href="https://github.com/browser-bugs/css-hacks/blob/gh-pages/property-value-space-backslash-9/length/index.html">Edit this page</a><br />
© 2016 <a href="http://browserbu.gs">Browser Bugs Working Group</a>. Content dual-licensed under <a href="https://github.com/browser-bugs/css-hacks/blob/gh-pages/LICENSE-MIT.txt">MIT</a> & <a href="https://github.com/browser-bugs/css-hacks/blob/gh-pages/LICENSE-CC-BY.txt">CC-BY-4.0</a>.<br />
<a href="https://twitter.com/browser_bugs" class="twitter">Twitter: @browser_bugs</a><br />
<a href="https://validator.w3.org/nu/?doc=http%3A%2F%2Fbrowserbu.gs%2Fcss-hacks%2Fproperty-value-space-backslash-9%2Flength%2F">Validate this HTML</a>
<p class="text-left"><small>All logos and trademarks are the property of their respective owners.</small></p>
</footer>
</div>
<script async src="../../ga.js"></script>
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/anchorjs/3.0.0/anchor.min.js" integrity="sha384-/u+jACBfKbiyZY8/EuEXH/XE/uihTXgvFlQs//rfYx3oNN5ZGi8O9VtikiuNBgAE"></script>
<script src="../../anchors.js"></script>
</body>
</html>