HTML contenteditable attribute

Contenteditable attribute allows the user to edit the content. Every element can use this attribute.

Example

<div contenteditable>
  The content inside every html element is editable because of 'contenteditable' attribute.
  By default, div element is not editable . But it becomes editable by the contenteditable attribute.
 </div>
Try </>

contenteditable attribute values

contenteditable attribute can be applied on all HTML elements. See the following example to understand.

<div> tag

div element is a block of content usually used to style the content.

Example

 <div contenteditable>
  This is a block of content and it is editable. It is the last priority of authors to write the content. It is used to style the content. 
 </div>
Try</>

<p> tag

Example

<p contenteditable>
This is a paragraph that is editable. We can add more text.
</p>
Try</>

<section> tag

contenteditable attribute applies to all the child elements. In the following example, contenteditable is applied on the section element and all the child elements of section element become editable.

Example

 <div contenteditable>
  This is a block of content and it is editable. It is the last priority of authors to write the content. It is used to style the content. 
 </div>
Try</>


Was this article helpful?

 

Email:

Message:

Get the newsletter