HTML global attribute contenteditable








The contenteditable attribute is new in HTML5 and allows the user to change the content in the page.

The following example shows how to use contenteditable attribute.

What's new in HTML5

The contenteditable attribute is new in HTML5.

Syntax

<element contenteditable="true|false">

Attribute Values

true
set element to editable
false
set element to not editable

Browser compatibility

contenteditable Yes Yes Yes Yes Yes




Example

<!DOCTYPE HTML>
<html>
<body>
   <p contenteditable="true">It is  raining right  now</p>
</body>
</html>

Click to view the demo

The code above applies the contenteditable attribute to a p element.

Setting the attribute value to true allows the user to edit the element contents, and setting it to false disables this feature.

If you don't specify a value, the element inherits the setting for this property from its parent.

The user clicks on the text and starts to type.