HTML contenteditable Attribute Examples
Example 1: In this example we use contenteditable attribute enables editing within specified elements. Here, a paragraph is made editable, allowing direct manipulation of its text content.
html
<!DOCTYPE html> < html > < head > < title >contenteditable attribute</ title > </ head > < body > < h2 >contenteditable attribute</ h2 > < p contenteditable = "true" > w3wiki: A computer science portal for geeks </ p > </ body > </ html > |
Output:
Example 2: In this example we use contenteditable attribute allows direct editing of specified elements. Here, paragraphs are made editable with “true” and “plaintext-only” values, enabling text manipulation within the webpage.
HTML
<!DOCTYPE html> < html > < head > < title >contenteditable attribute</ title > </ head > < body > < h2 >contenteditable attribute</ h2 > < p contenteditable = "true" > w3wiki </ p > < p contenteditable = "plaintext-only" > w3wiki </ p > </ body > </ html > |
Output:
HTML contenteditable Attribute
The HTML contenteditable attribute determines if element content is editable. It defaults to inheriting from the parent element. As a global attribute, it allows versatile content manipulation within the webpage directly.