css input textbox readonly to set background color not working

Glen picture Glen · Apr 18, 2016 · Viewed 21.5k times · Source

I have an old Classic ASP form that I need to add functionality to and I am using IE11. I decided to insert a doctype as follows (which I am not sure why or if it is necessary):

<!DOCTYPE html>

And added to my CSS file:

input[readonly] {
    background-color: #f6f6f6;
}

as other pages on this site suggest to change the background-color of a readonly textbox however it is not changing the color!

My HTML is declared as:

<input type="TEXT" readonly name="ORDERNO" value="<%=OrderNo%>" style="width:177px">

Any ideas why it is not working. There is no other styling applied that I can see that could potentially overwrite it. Is there anything else I need to post to clarify my issue?

Answer

satya picture satya · Apr 18, 2016

I have created a JSFiddle and it is working, please see the below link:

Try to change the background color to something bright color.

<input type="TEXT" readonly name="ORDERNO" value="<%=OrderNo%>" style="width:177px"

input[readonly] {
    background-color: red;
}

https://jsfiddle.net/nu2a4jbv/1/