@media (min-width: 0\0)
hackLast updated 2016-01-12.
@media (min-width: 0\0) { .your-selector-here { /* your declarations here */ } }
Sources: Browserhacks.com, Browser CSS Hacks by Paul Irish
If the square above shows the word "Affected", then your browser supports this hack.
This hack exploits a bug in the browser's parsing of CSS media queries.
Backslash (\
) is used as an escape character in CSS. So \0
is an escape sequence which notionally encodes the null character (␀).
However, presumably to prevent bugs related to potential use of null-terminated strings in browser implementations, the CSS Syntax Module Level 3 specifically treats \0
like an invalid escape sequence and requires that it result in the Unicode replacement character (U+FFFD; "�") instead of the null character.
But CSS Syntax Level 3 is a somewhat recent spec, and thus older browsers treat \0
differently.
At any rate, there are 4 obvious ways that browsers might parse 0\0
:
0�
, per the CSS Syntax Level 3 spec.0␀
, assuming the browser doesn't use null-terminated strings internally and doesn't treat null characters in CSS as syntax errors.0
, assuming the browser does use null-terminated strings internally and doesn't treat null characters in CSS as syntax errors. To be clear, this is a blatant implementation bug in the browser.
Cases 1 & 2 will ultimately lead to syntax errors, since neither �
nor ␀
are valid CSS length units, and min-width
's value must be a length.
That leaves Case 3. Since zero can be unitless in valid CSS (which is allowed because 0px = 0in = 0em
, etc.), the media query ends up being equivalent to @media (min-width: 0px)
, whose condition will always evaluate to True in any non-completely-insane browser.
Check out the links for corroborating screenshots.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
Chrome | OS X Safari |
iOS Safari |
Firefox | MS Edge1 | Internet Explorer |
48
Unknown |
10
Unknown |
9.3
Unknown |
46
Unknown |
13
Unknown |
|
47
Unaffected |
9.0.2
Unaffected |
9.2
Unaffected |
45.0a2
Unaffected |
12.10240
Unaffected |
11
Affected |
46
Unaffected |
8.0.8
Unaffected |
8.4
Unaffected |
44.0b7
Unaffected |
12.10166
Unknown |
10
Affected |
26
Unaffected |
7.1.7
Unaffected |
7.1
Unaffected |
43.0.4
Unaffected |
9
Affected |
|
25
Unknown |
6.2.7
Unaffected |
6.1
Unaffected |
4.0.1
Unaffected |
8
Unaffected2 |
|
5.1.7
Unknown |
5.1
Unknown |
7
Unknown |