HTML contenteditable Attribute

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

Definition and Usage

The contenteditable global attribute is an enumerated value that tells the browser whether an element’s content can be edited by the user. Use true (or an empty string) for rich editing, plaintext-only for text without formatting, or false to lock editing.

Editable elements can receive focus and join sequential keyboard navigation. Style the caret with CSS caret-color. For plain form fields, prefer <textarea> when you need normal form submission.

Baseline · Widely available.

Not deprecated and not experimental. Support for plaintext-only is newer in some browsers — check if you rely on it.

Not a boolean attribute.

Even though values include true / false, it is enumerated. Prefer an explicit value. Bare contenteditable equals an empty string (editable).

HTML Syntax

syntax.html
<element contenteditable=" true | false | plaintext-only">

An empty string (contenteditable="" or bare contenteditable) means editable, same as true.

Attribute Values

Allowed values and inheritance:

ValueDescriptionTry it
true or ""Element is editable (rich text / formatting may be kept on paste)Try it
falseElement is not editableTry it
plaintext-onlyRaw text editable; rich formatting disabled / stripped on pasteTry it
missing / invalidInherited from the parent elementTry it

Live Preview

Change the value, then click the box and type. Try pasting formatted text when using plaintext-only.

Click the region below and edit. Paste rich text to compare true vs plaintext-only.

editable region
Edit this text. Paste formatted content to test paste behavior.

contenteditable="true"

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Basic contenteditable="true"

Make a blockquote and cite editable — click and type.

HTML
<blockquote contenteditable="true">
  <p>Edit this content to add your own quote.</p>
</blockquote>

<cite contenteditable="true">-- Write your name here</cite>
Try It Yourself

How It Works

  1. contenteditable="true" turns the element into an editable region.
  2. Focus the element (click or Tab) and type like a text field.
  3. Works on many tags — headings, paragraphs, list items, and more.
  4. Not form data by default — read innerHTML / textContent with script if you need to save it.

Example 2 — true vs plaintext-only

Compare paste behavior: rich formatting kept vs stripped.

HTML
<p><strong>Copy this:</strong> <em>Italic</em> and bold text.</p>

<p>Rich editable:</p>
<div contenteditable="true">Paste here (formatting may remain).</div>

<p>Plain text only:</p>
<div contenteditable="plaintext-only">Paste here (formatting removed).</div>
Try It Yourself

How It Works

  1. true often keeps bold, lists, and other markup when pasting.
  2. plaintext-only keeps typing as text and strips rich paste formatting.
  3. Pick based on need — notes apps may want rich text; comments often want plain.
  4. Browser support for plaintext-only is newer — test your target browsers.

Example 3 — Nested editable + tabindex

Nested contenteditable regions are skipped in tab order unless you add tabindex.

HTML
<div contenteditable="true">
  Outer editable area.
  <p contenteditable="true" tabindex="0">
    Nested editable — Tab can focus this because of tabindex="0".
  </p>
</div>
Try It Yourself

How It Works

  1. Outer region is editable and focusable on its own.
  2. Nested regions are editable but omitted from the default tab sequence.
  3. tabindex="0" puts the nested region back into keyboard navigation.
  4. Inheritance: children without their own value inherit the parent’s editable state.

Edge Cases & Pitfalls

Editing in the page is powerful — keep accessibility and data handling in mind.

security

Sanitize before saving HTML

If you store innerHTML from an editable region, sanitize it. Users (or pasted content) can introduce unwanted markup.

forms

Not submitted automatically

Unlike <textarea>, editable divs are not form fields. Copy values into a hidden input or send them with script.

a11y

Label the editable region

Use a visible label or aria-label. Consider role="textbox" and aria-multiline="true" for custom editors.

keyboard

Nested Tab order

Add tabindex="0" when nested editable areas must be reachable with the keyboard.

naming

Not the meta content attribute

content on <meta> is unrelated metadata. Different attribute.

Browser Support

contenteditable is a global HTML attribute in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

contenteditable

Widely available since about July 2015. plaintext-only is newer — verify support if your product depends on it.

96% Global support (approx.)
Google Chrome All modern · plaintext-only supported
Full support
Mozilla Firefox All modern · check plaintext-only version
Full support*
Apple Safari All modern · plaintext-only supported
Full support
Microsoft Edge All modern · plaintext-only supported
Full support
Opera All modern
Full support
Samsung Internet All modern
Full support
Internet Explorer true/false · no plaintext-only
Partial*
contenteditable Widely supported

Bottom line: *Core editing is widely available. Treat plaintext-only as progressive enhancement if older engines matter.

Key Takeaways

  • Role: make almost any element user-editable in the page.
  • Values: true / "", false, plaintext-only (enumerated).
  • Inherit: missing/invalid values follow the parent.
  • Nested Tab: use tabindex="0" when needed.

One line: contenteditable turns elements into in-page editors — choose true or plaintext-only with care.

Frequently Asked Questions

It is a global enumerated attribute that makes an element’s content editable in the browser. Users can type into the element when it is set to true (or an empty string) or plaintext-only.
No. It is enumerated. Allowed values include true, false, plaintext-only, and an empty string (same as true). Missing or invalid values inherit from the parent.
The element’s raw text is editable, but rich formatting is disabled. Pasted content typically loses bold, links, and other markup.
textarea is a form control for plain text that submits with forms. contenteditable can edit almost any element and may allow rich formatting unless you use plaintext-only.
Nested contenteditable elements are not in the tab sequence by default. Add tabindex="0" when a nested region should be keyboard-focusable.
No. Meta content holds metadata values. contenteditable makes page content editable.

Next: controls

Show native play controls on audio and video elements.

controls 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.

8 people found this page helpful