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 a part of the Global Attributes.

The "contenteditable" attribute can have two values: true (the content is editable) or false (the content is not editable). If this attribute is not set on an element, the element will inherit it if its immediate parent element is editable.

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

Syntax

<tag contenteditable = "true|false"></tag>

Example of the HTML "contenteditable" attribute:

<!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>



Do you find this helpful?

Related articles