Favorites

HTML contenteditable Global Attribute

contenteditable
HTML Global AttributeThis global attribute is supported by all modern browsers.
Updated 22nd November 2026

The contenteditable attribute makes the content of an element editable by the user: true for rich text, plaintext-only for text only, or false.

☕
Enjoying this site?

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

Buy us a coffee

Description

The contenteditable global HTML attribute specifies whether the content of an element is editable by the user. It can be set to true (or an empty string), false or plaintext-only. If the attribute is not set, or has an invalid value, the element inherits its editability from its parent element.

With plaintext-only, the user can edit the text but not its formatting: rich text shortcuts such as Ctrl+B do nothing and pasted content is inserted as plain text.

When an element is editable, the user can click or tap on it to focus it and then start typing to edit its content. The user can also use keyboard shortcuts to edit the content, such as Ctrl+C to copy and Ctrl+V to paste.

The contenteditable attribute can be applied to any HTML element, such as <div>, <p> and <span>. This makes it a very versatile attribute for creating rich text editors, comment sections, and other forms of user-editable content.

Here are some examples of how to use the contenteditable attribute:

<p contenteditable="true">This paragraph is editable.</p>

<div contenteditable="true">This div element is editable.</div>

The contents of an editable element can be read and changed with JavaScript through innerHTML or textContent, and the input event fires as the user edits. The CSS :read-write pseudo-class matches editable elements.

Syntax

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

Values

  • trueIndicates that the element can be edited, including its formatting. An empty string has the same meaning.
  • falseIndicates that the element cannot be edited.
  • plaintext-onlyIndicates that the text of the element can be edited, but rich text formatting is disabled.

Example

<p contenteditable="true">contenteditable = true, try editing me.</p>
<p contenteditable="false">contenteditable = false, try editing me (it will not work!).</p>
<p contenteditable="plaintext-only">contenteditable = plaintext-only, try pasting formatted text here.</p>
Open in editor

Browser Support

The following information will show you the current browser support for the HTML contenteditable global attribute. Hover over a browser icon to see the version that first introduced support for this HTML global attribute.

This global attribute 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