Changing font colour in Textboxes in IE which are disabled

I noticed that you can change the colour of text in textboxes which are disabled in Firefox

I think what the question is trying to say is that this:

<textarea disabled="disabled" style="color: red;">Hello</textarea>

Results in grey text in IE, vs. red in Fox. FWIW, Opera also gives grey, whilst the WebKit browsers give red.

This is a pure CSS issue to do with how much form fields are rendered according to the OS's widget set and how much according to the CSS rules. This has always been an area of great cross-browser difference. Scripting is not relevant, much though SO would like “use jQuery” to be the answer to every question.

The usual workaround is to use ‘readonly’ instead of ‘disabled’, then use styling (eg. based off ‘class="disabled"’) to reproduce whatever shaded disabled effect you want. ‘readonly’ controls are not turned into OS-level-disabled widgets, giving you more latitude to style them.


     It should be noted that using the disabled attribute causes the underlying <input> element not to be submitted during a form submit, where as readonly controls are submitted to the server. Thus, you shouldn't use readonly if your server code isn't expecting a value from that control.

     It's been my experience that trying to hack something to get an acceptable presentation usually isn't worth it. I'd suggest you either change your CSS so that the fixed IE disabled text styling doesn't conflict with your underlying control style, or you use styled text in place of the control (since disabled controls aren't successful for submission anyways). Work with the browser and not against it.