This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.
The :read-write CSS pseudo-class represents an element (such as input or textarea) that is editable by the user.
label,
input[type="submit"] {
display: block;
margin-top: 1em;
}
*:read-write {
background-color: ivory;
border: 2px solid darkorange;
border-radius: 5px;
}
<p>Please fill in your details:</p> <form> <label for="email">Email Address:</label> <input id="email" name="email" type="email" value="[email protected]" /> <label for="note">Short note about yourself:</label> <textarea id="note" name="note">Don't be shy</textarea> <label for="pic">Your picture:</label> <input id="pic" name="pic" type="file" /> <input type="submit" value="Submit form" /> </form>
:read-write {
/* ... */
}
You can use readonly form controls when you want a user to verify information they entered earlier, which you want to submit with new data in read-write controls. In the example below, the :read-only pseudo-class is used to make the <textarea> (a user's address) look like a regular paragraph. The :read-write pseudo-class provides a way to highlight the editable <textarea> (the delivery instructions):
textarea:read-only {
border: 0;
}
textarea:read-write {
box-shadow: inset 1px 1px 3px #cccccc;
border-radius: 5px;
}
<form>
<fieldset>
<legend>Confirm details</legend>
<div>
<label for="address">Address:</label>
<textarea id="address" name="address" readonly>
123 Choco Mountain,
Awesome Ridge,
CA</textarea
>
</div>
<div>
<label for="instructions">Delivery instructions</label>
<textarea id="instructions" name="instructions"></textarea>
</div>
</fieldset>
<button type="submit">Confirm</button>
</form>
This selector doesn't just select <input>/<textarea> elements — it will select any element that can be edited by the user, such as a <p> element with contenteditable set on it.
<p contenteditable>This paragraph is editable; it is read-write.</p> <p>This paragraph is not editable; it is read-only.</p>
body {
font-family: sans-serif;
}
p {
font-size: 150%;
padding: 5px;
border-radius: 5px;
}
p:read-only {
background-color: red;
color: white;
}
p:read-write {
background-color: lime;
}
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
:read-write |
1 | 13 | 781.5 | 9 | 4 | 18 | 794 | 10.1 | 3.2 | 1.0 | 4.4 | 3.2 |
:read-onlycontenteditable attribute
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/:read-write