CSS :read-write Pseudo-Class

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The :read-write pseudo-class matches elements the user can edit — typically input / textarea without readonly (and not disabled), plus contenteditable content.

Pair it with :read-only when a form mixes locked confirmation fields and still-editable ones (for example delivery instructions).

Baseline — widely available.

Supported across modern browsers (MDN: widely available since July 2020). Prefer scoped selectors such as textarea:read-write when you only want form controls.

CSS Syntax

syntax.css
:read-write { /* styles */ }

Example: textarea:read-write { outline: 1px dashed #dc2626; }.

What It Matches

:read-write has no values — it is a state. Typical matches:

TargetNotesTry it
input:read-writeEditable text-like inputs (no readonly)Try it
textarea:read-writeEditable multi-line fieldsTry it
With :read-onlyContrast editable vs locked fieldsTry it
[contenteditable]Editable non-form elementsTry it
:disabledDoes not match — not editableExcluded

How to Use :read-write

Leave the field editable in HTML, then highlight that state in CSS.

  1. Use a normal input / textarea (no readonly, not disabled).
  2. Select with input:read-write or textarea:read-write.
  3. Add a clear visual cue (border, outline, or soft background).
  4. Mute confirmation fields with :read-only in the same form.
PieceRequired?Role
Editable controlYesNo readonly / not disabled
:read-write ruleYesVisual cue for writable fields
Scoped selectorRecommendedAvoid styling every editable node on the page
:read-onlyOptionalMute locked fields for contrast

Live Preview

Toggle between editable and readonly. The dashed outline applies only while the field matches :read-write.

Rule shown: textarea:read-write

Field

Matches :read-write — dashed outline

CSS Examples

Short patterns for editable fields. Use Try It Yourself for a live editor.

Example 1 — Editable Input

Highlight a writable email field.

CSS
<style>
  input:read-write {
    border: 2px solid #ea580c;
    background: #fffbeb;
  }
</style>

<label>
  Email
  <input type="email" value="[email protected]">
</label>
Try It Yourself

How It Works

  1. No readonly — the input stays editable.
  2. input:read-write matches that writable state.
  3. Border + soft fill signal “type here.”
  4. Add readonly and the rule stops applying.

Example 2 — Pair with :read-only

Mute locked address text; emphasize editable instructions.

CSS
<style>
  textarea:read-only {
    border: 0;
    background: #f1f5f9;
  }
  textarea:read-write {
    box-shadow: inset 1px 1px 3px #ccc;
  }
</style>

<textarea readonly>123 Choco Mountain</textarea>
<textarea>Delivery notes</textarea>
Try It Yourself

How It Works

  1. First textarea has readonly → matches :read-only.
  2. Second textarea is editable → matches :read-write.
  3. Inset shadow marks the field users can still change.
  4. Same pattern as MDN’s confirm-details example.

Example 3 — contenteditable

Non-form text can also match :read-write.

CSS
<style>
  p:read-write {
    background: #bbf7d0;
  }
  p:read-only {
    background: #fecaca;
    color: #7f1d1d;
  }
</style>

<p contenteditable>Editable paragraph</p>
<p>Fixed paragraph</p>
Try It Yourself

How It Works

  1. contenteditable makes the first p user-editable.
  2. It matches :read-write → green background.
  3. The plain p matches :read-only → red tint.
  4. Scope carefully if you do not want every paragraph styled.

Edge Cases & Pitfalls

Editable state is the key — disabled and readonly never match.

disabled

Disabled is not read-write

A disabled control cannot be edited. Style it with :disabled, not :read-write.

readonly

readonly flips to :read-only

As soon as you add readonly, :read-write stops matching. Use that toggle for confirmation steps.

scope

Not only form controls

contenteditable nodes also match. Prefer input:read-write / textarea:read-write for forms.

a11y

Keep focus styles

A decorative outline for :read-write should not replace a clear :focus / :focus-visible indicator.

Browser Support

:read-write is a browser CSS pseudo-class. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

:read-write

Widely available across modern browsers (MDN notes broad support from mid-2020). Pair with :read-only for form UX. Internet Explorer had incomplete / prefixed support historically.

97% Widely available
Google Chrome Supported
Full support
Mozilla Firefox Supported
Full support
Apple Safari Supported
Full support
Microsoft Edge Supported
Full support
Opera Supported
Full support
Samsung Internet Supported
Full support
Internet Explorer Partial
Legacy / incomplete
:read-write Baseline · Widely available

Bottom line: Safe for modern form styling. Scope to input/textarea when needed. This is not a JavaScript runtime API.

Key Takeaways

  • Role: style elements the user can edit.
  • Pair with :read-only for locked vs editable fields.
  • Start simple: textarea:read-write { outline: …; }.
  • Excluded: readonly and disabled never match.

One line: :read-write paints “you can type here” — highlight it, and mute the rest with :read-only.

Frequently Asked Questions

It matches elements the user can edit — typically input and textarea without readonly (and not disabled), plus contenteditable elements.
:read-write matches editable controls. :read-only matches non-editable ones. They are natural pairs for confirmation vs editable fields in the same form.
No. Disabled controls are not editable. Use :disabled for inactive fields and :read-write only for controls users can type into.
Yes. Any user-editable element can match, such as a paragraph with contenteditable. Scope your selector if you only want form controls.
No. It is a browser CSS pseudo-class. Node.js, Deno, and Bun do not apply it.

Next: :required

Learn how to style fields that must be completed before submit.

:required tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful