Home >CSS >Introduction to CSS >How to style a read-only input

How to style a read-only input

When an input is readonly or disabled, it is good to make it look different from the others so that users see the difference right away. How to do it?

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

This is enough, but it can also be written in a more complete way:
textarea[readonly="readonly"], textarea[readonly]
{
    background-color: blue;
}