HTML contenteditable Global Attribute
The contenteditable attribute makes the content of an element editable by the user: true for rich text, plaintext-only for text only, or false.
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
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.
Desktop





Tablets & Mobile





