html tutorial - contenteditable Attribute in HTML - html5 - html code - html form



Contenteditable attribute in html

Learn html - html tutorial - Contenteditable attribute in html - html examples - html programs

  • The contenteditable attribute defines if the content of an element is rewrite or not.
  • The contenteditable attribute is a section of the Global Attributes.

Syntax for contenteditable attribute in HTML:

<element contenteditable="true|false">content</element>

Difference between HTML 4.01 and HTML 5 for contenteditable Attribute:

HTML 4.01

  • The contenteditable attribute has not been defined.

HTML 5

  • The contenteditable attribute is added newly in HTML5.

Applies To:

Element Attribute
All HTML Elements contenteditable

contenteditable Attribute Values:

Value HTML 4.0.1 HTML 5 Description
true No Yes Defines if the element is rewrite.
false No Yes Defines if the element is not rewrite.

Sample Coding for contenteditable Attribute in HTML:

Tryit<!DOCTYPE html>
<html>
    <head>
        <title>Wikitechy contenteditable attribute</title>
    </head>
    <body>
        <p contenteditable="true">
             Wikitechy is an enhanced tutorials zone providing
             the best learning curve.                     
        </p>
    </body>
</html>

Code Explanation for contenteditable Attribute in HTML:

contenteditable Attribute Code Explanation

  1. <p> tag is used to defined the content in a paragraph.
  2. contenteditable is an attribute, which describes if the content of an element is edit or not. (Here the value of contenteditable is true, the content is editable.)

Output for contenteditable Attribute in HTML:

contenteditable Attribute Output

  1. The Output shows the <p> tag contents.
  2. contenteditable Attribute Output
  3. The content has contenteditable attribute, so the user can edit the content.

Browser Support for contenteditable Attribute in HTML:

4.0 6.0 3.5 3.1 10.1

Tips and Notes

  • If the contenteditable attribute is not specified on an element, the element will derive from its parent.

Related Searches to contenteditable Attribute in html