16

What rule do you need to enable styling of disabled elements in IE8? I have the code below now. It that works fine under IE7, but not on IE8. IE8 just give me plaint wihte background. Why?

input[disabled], input:disabled, textarea[disabled], textarea[disabled="disabled"], textarea:disabled {
    background:#EBEBE4;
}
Patrick
  • 13,872
  • 5
  • 35
  • 53
Marwelln
  • 28,492
  • 21
  • 93
  • 117

2 Answers2

32

the :pseudo class in the selector is tripping up IE8!

you have to ungroup these selectors if you absolutely have to use those CSS3 pseudo classes;

If there's a selector in the ruleset that IE8 doesn't understand it's ignoring the whole thing - this is common in IE8 with CSS3 pseudo classes

e.g. If you separate them out and remove the pseudo :disabled parts of the selector completely - you'll see the first example below works for all, whereas the second one still works except for IE7

input[disabled], select[disabled], textarea[disabled] {background-color: #0f0;} /* lime green - works in IE7+ and modern browsers */

input[disabled="disabled"], select[disabled="disabled"], textarea[disabled="disabled"] {background-color:#ff0;} /* yellow -  IE8+ and modern browsers */

the color (as opposed to background-color) issue pointed at in another answer is not the cause of your issue, but it wouldn't help if you were also trying to change the color ;)

Community
  • 1
  • 1
clairesuzy
  • 27,296
  • 8
  • 54
  • 52
6

Another option is to add a disabled class and style it:

input.disabled, textarea.disabled{ 
    background:#EBEBE4; 
}
bluefoot
  • 10,220
  • 11
  • 43
  • 56
  • 1
    This answer is really underrated. It also works really well for similar problems, like for instance if you would want paired elements to show a hover-style simultainiously, when only one of them has a mouseover. – jumps4fun May 19 '14 at 08:27