CSS :read-write Selector

Beginner
⏱️ 6 min read
📚 Updated: Jul 2026
🎯 4 Examples
Form States

What You’ll Learn

The :read-write pseudo-class styles form fields users can edit. Pair it with :read-only to give editable inputs a bright, interactive look that stands out from locked values.

01

Editable

User can type.

02

:read-only

Locked pair.

03

input

Text fields.

04

textarea

Multi-line.

05

:focus

Focus ring.

06

vs disabled

Active fields.

Introduction

The CSS :read-write selector targets form elements that users can edit — fields where they can type, paste, or modify content. It matches <input> and <textarea> elements that are not marked readonly or disabled.

It is the counterpart to :read-only. Use :read-write to highlight fields users should interact with, making forms clearer and more intuitive.

Definition and Usage

Use :read-write on its own or scoped: input:read-write or textarea:read-write. Combine with :focus for enhanced focus styling on editable fields.

💡
Beginner Tip

Always pair :read-write with :read-only in the same form. Editable fields get bright styling; locked fields get muted gray styling. Users instantly know what they can change.

📝 Syntax

The syntax for the :read-write pseudo-class is:

syntax.css
:read-write {
  /* CSS properties */
}

The :read-write pseudo-class targets form controls that accept user input and are not locked or disabled.

Basic Example

read-write.css
:read-write {
  background-color: #eff6ff;
  border: 2px solid #3b82f6;
  color: #1e293b;
}

:read-only {
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #64748b;
}
input:read-write textarea:read-write input:read-write:focus :read-only

:read-write vs :read-only

StateMatchesTypical styling
:read-writeEditable fields (no readonly/disabled)White/blue background, solid border
:read-onlyFields with readonlyGray background, muted text
:disabledFields with disabledGrayed out, not interactive

Syntax Rules

  • Matches inputs and textareas without readonly or disabled.
  • Pair with :read-only for complete editable vs locked styling.
  • Combine with :focus: input:read-write:focus for focus rings.
  • Scope with element selectors: input:read-write for targeted rules.
  • Does not typically apply to select or button elements.

Related Selectors

  • :read-only — matches non-editable form controls
  • :disabled — matches inactive, non-interactive controls
  • :enabled — matches controls without the disabled attribute
  • :focus — matches the currently focused editable field
  • :optional — matches non-required form fields

⚡ Quick Reference

QuestionAnswer
Selector typePseudo-class (UI state)
When it appliesField is editable by the user
Excludesreadonly and disabled fields
Best paired with:read-only
Common propertiesbackground-color, border, box-shadow
Browser supportAll modern browsers

When to Use :read-write

:read-write is ideal for highlighting editable form fields:

  • Mixed edit forms — Brighten fields users can change alongside locked system values.
  • Profile settings — Style editable display name, bio, and email fields.
  • Comment boxes — Give writable textareas a clear interactive appearance.
  • Onboarding wizards — Draw attention to fields awaiting user input.
  • Focus enhancement — Combine with :focus for polished keyboard navigation.

👀 Live Preview

Editable fields use blue styling via :read-write. The locked Order ID uses :read-only gray styling:

Examples Gallery

Practice :read-write with basic pairing, focus rings, textarea styling, and complete forms.

📜 Core Patterns

Highlight editable fields with bright styling paired against read-only fields.

Example 1 — Basic :read-write and :read-only

Style editable username and bio fields blue; keep the read-only field gray.

read-write-form.html
<style>
  :read-write {
    background: #eff6ff;
    border: 2px solid #3b82f6;
    color: #1e293b;
  }
  :read-only {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #64748b;
  }
  input, textarea {
    padding: 0.5rem;
    border-radius: 0.4rem;
    width: 100%;
    margin-bottom: 0.75rem;
  }
</style>

<form>
  <input type="text" placeholder="Enter username">
  <textarea placeholder="Write about yourself"></textarea>
  <input type="text" value="Read-only value" readonly>
</form>
Try It Yourself

How It Works

The username input and textarea match :read-write with blue borders. The field with readonly matches :read-only instead with gray styling.

Example 2 — Focus ring on :read-write:focus

Add a blue glow when the user focuses an editable field.

read-write-focus.css
input:read-write {
  background: #fff;
  border: 2px solid #cbd5e1;
  padding: 0.5rem 0.75rem;
  border-radius: 0.4rem;
  transition: box-shadow 0.2s ease;
}

input:read-write:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}
Try It Yourself

How It Works

Only editable fields match input:read-write:focus. Read-only or disabled fields won’t get the focus ring from this rule.

📄 Textareas & Forms

Style writable textareas and complete registration forms.

Example 3 — Writable textarea styling

Give editable textareas a white background and vertical resize, while read-only ones stay locked.

read-write-textarea.css
textarea:read-write {
  background: #fff;
  border: 2px solid #cbd5e1;
  color: #1e293b;
  resize: vertical;
  min-height: 5rem;
}

textarea:read-only {
  background: #f1f5f9;
  resize: none;
}
Try It Yourself

How It Works

Writable textareas get resize: vertical so users can expand them. Read-only textareas use resize: none to signal they cannot be edited.

Example 4 — Registration form with mixed fields

Highlight all editable fields in a signup form while keeping the invite code read-only.

read-write-signup.css
.signup-form input:read-write {
  background: #fff;
  border: 2px solid #e2e8f0;
  color: #1e293b;
}

.signup-form input:read-write:focus {
  border-color: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
  outline: none;
}

.signup-form input:read-only {
  background: #f8fafc;
  border: 1px dashed #94a3b8;
  color: #64748b;
}
Try It Yourself

How It Works

The invite code is locked with readonly and styled via :read-only. Name and email fields match :read-write with green focus rings when the user clicks in.

💬 Usage Tips

  • Pair with :read-only — Always style both states in mixed forms for clear contrast.
  • Add :focus styling — Use input:read-write:focus for accessible focus rings.
  • Scope selectors — Use input:read-write within form wrappers.
  • Bright = editable — White backgrounds and colored borders signal interactivity.
  • Exclude disabled — Disabled fields won’t match; style them with :disabled.
  • Test mixed forms — Verify readonly, editable, and disabled fields each get correct styles.

⚠️ Common Pitfalls

  • Confusing with :enabled:enabled only checks disabled; :read-write also excludes readonly.
  • Missing :read-only pair — Styling only editable fields leaves locked fields looking interactive.
  • Select dropdowns:read-write behavior on select varies; test cross-browser.
  • Disabled fields — They do not match :read-write; use :disabled instead.
  • Over-bright styling — Editable fields should stand out but still meet contrast guidelines.
  • Security — Visual styling does not prevent editing; use server validation.

♿ Accessibility

  • Visible focus — Always provide a clear focus indicator on :read-write:focus.
  • Label all fields — Editable and read-only fields both need <label> elements.
  • Don’t rely on color alone — Pair visual cues with clear label text.
  • Keyboard navigation — Ensure tab order reaches all editable fields.
  • Explain locked fields — Label text like “Invite code (pre-filled)” helps screen reader users.

🧠 How :read-write Works

1

Field is editable

No readonly or disabled attribute is set on the input or textarea.

HTML
2

:read-write matches

CSS rules targeting :read-write apply bright, interactive styling.

CSS
3

User types or focuses

Combine with :focus for enhanced feedback during interaction.

UX
=

Clear editable feedback

Users know exactly which fields they can change.

🖥 Browser Compatibility

The :read-write pseudo-class is supported in all modern browsers.

Baseline · Modern browsers

Editable field styling everywhere

:read-write works in Chrome, Firefox, Safari, Edge, and Opera.

99% Global support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions
Full support
Opera All versions
Full support
:read-write pseudo-class 99% supported

Bottom line: Safe for all modern form UI. Pair with :read-only for complete field state styling.

🎉 Conclusion

The :read-write selector is a handy pseudo-class for styling editable fields, allowing you to visually distinguish elements users can interact with from those they cannot. By applying bright, focused styling, you enhance user experience and provide clear visual cues for writable content.

Pair it with :read-only in every mixed form, add :focus rings for accessibility, and remember that styling is a UX aid — always validate on the server.

💡 Best Practices

✅ Do

  • Pair :read-write with :read-only
  • Add :focus styling for keyboard users
  • Use bright backgrounds for editable fields
  • Scope rules with input:read-write
  • Label every field clearly

❌ Don’t

  • Style only editable fields in mixed forms
  • Confuse :read-write with :enabled
  • Forget disabled fields need :disabled
  • Remove visible focus indicators
  • Rely on styling alone for field protection

Key Takeaways

Knowledge Unlocked

Five things to remember about :read-write

Use these points when styling editable form fields.

5
Core concepts
:ro 02

:read-only

Locked pair.

Tip
:focus 03

Focus ring

Accessibility.

A11y
🚫 04

Not disabled

Active fields.

State
🌐 05

99% support

All browsers.

Compat

❓ Frequently Asked Questions

The :read-write pseudo-class matches form elements that users can edit — fields without the readonly attribute that are not disabled. It lets you style writable inputs and textareas with distinct visual treatment.
:read-write applies to editable input and textarea elements, and to elements with contenteditable set to true. It does not match fields with readonly or disabled attributes.
:read-write matches editable fields users can type into. :read-only matches the opposite — fields locked with the readonly attribute. They are natural pairs for form styling.
No. Disabled fields are not editable and do not match :read-write. Use :disabled for inactive controls and :read-write only for fields users can interact with.
:read-write is supported in all modern browsers including Chrome, Firefox, Safari, and Edge.

Practice in the Live Editor

Open the HTML editor and experiment with :read-write, :read-only, and form state styling.

HTML Editor →

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