Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Pseudo-classes

The :read-write pseudo-class

Reference for the CSS :read-write pseudo-class: match editable text inputs, textareas and contenteditable elements that the user can change, with examples.

The :read-write pseudo-class matches elements whose content the user can edit. That means text-like <input> and <textarea> elements without readonly or disabled, and any element made editable with contenteditable.

It is the opposite of :read-only, and it is a nice way to style "live" editing areas without extra classes.

CSS
[contenteditable]:read-write {
  outline: 2px dashed #2563eb;
}

Try it

Editable regions stand out

Syntax

CSS
:read-write { /* declarations */ }
  • Applies to: editable form controls and elements in an editable host (such as contenteditable).
  • Specificity: (0,1,0).
  • Inherited / animatable: not applicable.

Values

Syntax and arguments Description
:read-write No arguments. Matches an element the user can edit, such as a text input or textarea that is neither readonly nor disabled, or an element in contenteditable content.

Usage notes

  • Covers contenteditable. Unlike :enabled, it also matches non-form elements that are editable, and the children of an editable element.
  • Text-like controls only. Inputs of types that don't hold editable text (buttons, checkboxes, range, color) are not read-write.
  • Disabled is excluded. A disabled input never matches; a readonly input never matches.
  • Combine with :is(). To limit it to form controls, write :read-write:is(input, textarea) or input:read-write.
  • Children inherit editability. Every element inside a contenteditable host also matches. A rule like [contenteditable] :read-write may be broader than you want.
  • Accessibility. An outline or colour change should keep sufficient contrast. Don't remove the focus indicator when styling.

Browser support

Supported in all current browsers. Very old Firefox needed the :-moz-read-write prefix.