Notes on Day 16 of 30 Days of JavaScript

Table of Contents

Lessons Learned

HTMLElement.contenteditable

The contentEditable attribute specifies if the element is editable or not. Its default value is 'true' and can also be 'false' and 'inherit'.

<h1 contenteditable>This is the title</h1>

This does not affect input and textarea elements regardless if set to false. You can still enter text to them. Only the disabled attribute would prevent entering data.

In terms of inheritance, it will only take effect if the 'inherit' value is explicitly set to a children.

<div contenteditable="false">
  <p>This paragraph is not editable</p>
  <p contenteditable="inherit">This paragraph is not editable</p>
  <p contenteditable="true">This paragraph is editable</p>
</div>

References

Twitter, LinkedIn