What conditions should be matched for a <select> to get the :read-only pseudo element?
Quoting The Mutability Pseudo-classes docs:
An element matches :read-write if it is user-alterable, as defined by the document language. Otherwise, it is :read-only.
Quoting the :read-only HTML Specs:
The :read-write pseudo-class must match any element falling into one of the following categories, which for the purposes of Selectors are thus considered user-alterable: [SELECTORS]
<input> elements to which the readonly attribute applies, and that are mutable (i.e. that do not have the readonly attribute specified and that are not disabled)
<textarea> elements that do not have a readonly attribute, and that are not disabled
- Elements that are editing hosts or editable and are neither
<input> elements nor <textarea> elements
The :read-only pseudo-class must match all other HTML elements.
So for a <select> to get the read-only attribute, it must not be
- User-alterable
- An editing host
- Editable
Addressing these criteria one by one
- User-alterable
Looking for a quote to back this
- An editing host
Quoting the whatwh editing host definition specs:
An editing host is either an HTML element with its contenteditable attribute in the true state or plaintext-only state, or a child HTML element of a Document whose design mode enabled is true.
Clearly, the <select> does not match these criteria
- Editable
Again, quoting the relevant common definitions specs:
Something is editable if it is a node; it is not an editing host; it does not have a contenteditable attribute set to the false state; its parent is an editing host or editable; and either it is an HTML element, or it is an svg or math element, or it is not an Element and its parent is an HTML element.
A <select> is of type HTMLElement, so without the contenteditable attribute, it's not editable