Skip to content

HTML contenteditable Attribute

The HTML contenteditable attribute is used to specify whether or not the content of an element is editable.

You can use this attribute on any HTML element. It is part of the Global Attributes.

The contenteditable attribute accepts true, false, or inherit. An empty string ("") is also valid and behaves identically to true. If the attribute is omitted, the element inherits the value from its parent.

DANGER

The contenteditable attribute does not have an effect on disabled elements.

Syntax

Syntax of HTML contenteditable attribute

html
<tag contenteditable="true|false">&lt;/tag&gt;

Example of the HTML contenteditable attribute:

Example of the HTML "contenteditable" attribute

html
<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <p contenteditable="false">
      This is a paragraph. It is not editable.
    </p>
    <p contenteditable="true">
      This is a paragraph. It is editable. Try to change this text.
    </p>
  </body>
</html>

Practice

Which of the following statements are true regarding the HTML contenteditable attribute?

Dual-run preview — compare with live Symfony routes.