CSS Portal

:read-write CSS Pseudo Class

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
:read-write
CSS Pseudo ClassThis pseudo class is supported by all modern browsers.
Updated 31st December 2025

Description

The :read-write pseudo-class in CSS is used to select elements that are editable by the user, meaning elements whose content can be modified. It specifically targets elements that are not readonly and are capable of accepting user input. This makes it particularly useful for styling form elements such as <input> and <textarea> fields, or elements with the contenteditable attribute. When an element is in a state where the user can write or modify its content, it matches the :read-write pseudo-class.

This pseudo-class is the counterpart to :read-only, which selects elements that cannot be modified by the user. A key point is that :read-write does not require the element to be actively focused; it simply needs to be in an editable state. You can use it in combination with other pseudo-classes, such as :focus, to create specific styling rules for editable elements that are currently focused.

For example, you might want to highlight all editable fields with a subtle background color to make it clear which areas of a form are interactive:

<input type="text" placeholder="Enter your name">
<textarea placeholder="Write a comment"></textarea>
<div contenteditable="true">Editable content here...</div>
input:read-write,
textarea:read-write,
div:read-write {
    background-color: #f0f8ff;
    border: 1px solid #1e90ff;
    padding: 0.5em;
}

In this example, any <input> or <textarea> field that is editable, as well as the <div> with contenteditable="true", will receive a light blue background and a blue border.

The :read-write pseudo-class is often paired with color, background-color, border, and outline to provide clear visual feedback to users about editable areas. This enhances usability and accessibility, making forms and interactive content more intuitive.

Syntax

:read-write {
  /* ... */
}

Example

<form>
<label for="username">Username (editable):</label>
<input type="text" id="username" placeholder="Enter your username">
<br><br>
<label for="email">Email (read-only):</label>
<input type="email" id="email" value="user@example.com" readonly>
<br><br>
<label for="bio">Bio (editable div):</label>
<div id="bio" contenteditable="true">Write something about yourself...</div>
</form>
/* Style editable elements */
input:read-write,
div:read-write {
background-color: #f0f8ff;
border: 1px solid #1e90ff;
padding: 0.5em;
border-radius: 4px;
}

/* Optional: style read-only elements differently */
input:read-only {
background-color: #f5f5f5;
border: 1px solid #ccc;
color: #888;
padding: 0.5em;
border-radius: 4px;
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS :read-write pseudo class. Hover over a browser icon to see the version that first introduced support for this CSS pseudo class.

This pseudo class is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee