CKTIS / CSS
:read-only — non-editable elements
The :read-only pseudo-class selects elements that are not user-editable under the document language’s rules. It is not equivalent to [readonly]: in HTML, it also matches ordinary paragraph elements and disabled fields. It does not match text nodes.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
:read-only:read-only is a pseudo-class with no arguments. It matches elements that do not match :read-write; editability follows the document language’s rules, not merely the presence of the readonly attribute.
In HTML, :read-write covers mutable, enabled input fields that support readonly, enabled textarea elements without readonly, and other editable elements, for example through contenteditable. All remaining elements match :read-only, including an ordinary paragraph and a disabled field. Being able to click a control therefore does not imply matching :read-write.
Use input:read-only to restrict the scope to input fields, or [readonly] when you specifically mean attribute presence. The selector itself blocks nothing and is not a data-security mechanism. The example scopes styling with .sample; the expected result text is locked, disabled, text.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>:read-only demo</title>
<style>
.sample:read-only { outline: 3px solid #805000; }
</style>
<label>Editable: <input class="sample" id="editable" type="text" value="A"></label>
<label>Readonly: <input class="sample" id="locked" type="text" value="B" readonly></label>
<label>Disabled: <input class="sample" id="disabled" type="text" value="C" disabled></label>
<p class="sample" id="text">Static text</p>
<pre id="result"></pre>
<script>
const matches = document.querySelectorAll('.sample:read-only');
document.getElementById('result').textContent =
Array.from(matches, element => element.id).join(', ');
</script>
</html>Result
locked, disabled, text
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.