Skip to content
Related Articles

Related Articles

HTML | contenteditable Attribute

Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 24 Aug, 2022
Improve Article
Save Article

It is used to specify whether the content present in the element is editable or not. When this attribute is not set in an element, this element will inherit from its parent element.
Supported Tags: It supports all HTML elements. 

Syntax: 
 

<element contenteditable = "true|false">

Attribute: It is mainly an instance of a Global Attributes and it can be used in any HTML elements. This attribute contains two value either true or false. If the attribute value is true then the content is editable and if the attribute value is false the content is not editable.
Example: 
 

html




<!DOCTYPE html>
<html>
    <head>
        <title>contenteditable attribute</title>
        <style>
            body {
                width:60%;
                text-align:center;
            }
            h1 {
                color:green;
            }
        </style>
    </head>
    <body>
        <h1>GeeksforGeeks</h1>
        <h2>contenteditable attribute</h2>
        <p contenteditable="true">GeeksforGeeks:
         A computer science portal for geeks</p>
 
 
    </body>
</html>                   

Output: 
 

Supported Browsers: The browser supported by contenteditable attribute are listed below: 
 

  • Google Chrome 
  • Edge 12 and above
  • Firefox 3 and above
  • Opera 9 and above
  • Safari 

 

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!