readonly
and disabled
are different, that's why :read-only
will not work with disabled
.
Check here Best Practice - ReadOnly vs Disabled in Form Controls
Now your next question: "...but the description of "read-only" pseudo-class is that it applies to any element that cannot be editable..."
One use of readonly form controls is to allow the user to check and
verify information that they may have entered in an earlier form (for
example, shipping details), while still being able to submit the
information along with the rest of the form...
Source :read-only
If you connect 1st answer and the highlighted description here you can see, it won't be working for disabled (The value of the "disabled" control will not be submitted with the form)
What if you have both types of control in form and you only wants to style read-only
. Then it won't be possible with one fits all approach
To style readonly
you may need to add readonly
attribute to the desired elements.
.pseudo-test input:read-write {
color: blue;
}
.pseudo-test input:read-only {
color: red;
}
<div style="margin-top:10px" class="pseudo-test">
<form action="another-action.php">
<input type="search" value="What do you want to search for?" size="100" readonly>
</form>
</div>