background-color: color\9;
hackLast updated 2016-01-20.
.your-selector-here { background-color: somecolor\9; }
…where somecolor
is a CSS color value.
Source: Browser CSS Hacks by Paul Irish
Important note!
This article only applies to the background-color
property and only applies when there is no space between somecolor
and \9
.
Adding spaces or using different properties changes the compatibility of the hack.
You have been warned.
If the rectangle above is light green, then your browser supports this hack for color keyword values (e.g. lime
).
If the rectangle above is light green, then your browser supports this hack for RGB colors in hexadecimal notation (e.g. #adff2f
).
If the rectangle above shows the word "Affected" on a green background, then your browser supports this hack for the transparent
keyword color value.
If the rectangle above is light green, then your browser supports this hack for RGB colors in functional notation (e.g. rgb(173, 255, 47)
).
Backslash (\
) is used as an escape character in CSS. So \9
is an escape sequence which encodes the tab character (U+0009). Presumably the affected browsers are interpreting it like a literal tab character and thus ignoring it when parsing background-color
values, since whitespace between the value and the semicolon that ends a declaration doesn't matter in CSS (something like background-color: red ;
is perfectly valid).
The hack seems to work for colors represented using any syntax in IE8. It seems to work for colors represented using any syntax except functional notation (e.g. rgb(173, 255, 47)
) in IE9-10 (see Note 2).
The hack doesn't seem to work in IE11 or any other browser.
Check out the links for corroborating screenshots.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
Chrome | OS X Safari |
iOS Safari |
Firefox | MS Edge1 | Internet Explorer |
49
Unknown |
10
Unknown |
9.3
Unknown |
46
Unknown |
13
Unknown |
|
48
Unaffected |
9.0.2
Unaffected |
9.2
Unaffected |
45.0a2
Unaffected |
12.10240
Unaffected |
11
Unaffected |
47
Unaffected |
8.0.8
Unaffected |
8.4
Unaffected |
44.0b7
Unaffected |
12.10166
Unknown |
10
Affected2 |
26
Unaffected |
7.1.7
Unaffected |
7.1
Unaffected |
43.0.4
Unaffected |
9
Affected2 |
|
25
Unknown |
6.2.7
Unknown |
6.1
Unknown |
4.0.1
Unaffected |
8
Affected |
|
7
Unknown |
rgb(173, 255, 47)
) is not compatible with this hack.