3

I'm having very different behaviors with nested contenteditable="false" elements within a parent contenteditable="true:

  <pre>
  <div contenteditable="true">
    <span>I'm supposed to be editable</span>
    <p contenteditable="false">I'm NOT supposed to be editable.<br>Neither should I.</p>
    <span contenteditable="false">I'm NOT supposed to be editable.</span>
  </div>
  </pre>

This fiddle exemplifies how two elements that should not be editable are in fact editable with Internet Explorer 11 but not Google Chrome. What gives?

I have seen some people applying a strange workaround by setting them to "true", which indeed works for IE, but has the opposite effect on Google Chrome (as it should).

The answer for this similar question is dated from 2013. Three years after, is this still the current scenario ?

Edit: This fiddle almost achieves the wanted result. However, if you set the cursor to "Don't move.." and move it to the left until you reach the non-editable span, you will gain focus and able to edit it. Any ideas to avoid this behavior ?

Affected browser: Internet Explorer 11

Community
  • 1
  • 1
pelican_george
  • 961
  • 2
  • 13
  • 33

1 Answers1

6

This is a bug in Internet Explorer 11. Section 7.6.1 of the HTML5 specification states:

The contenteditable attribute is an enumerated attribute whose keywords are the empty string, true, and false. The empty string and the true keyword map to the true state. The false keyword maps to the false state. In addition, there is a third state, the inherit state, which is the missing value default (and the invalid value default).

The true state indicates that the element is editable. The inherit state indicates that the element is editable if its parent is. The false state indicates that the element is not editable.

This means that a contenteditable=false element within a contenteditable=true element should not be editable.

Furthermore, a contenteditable=true element within a contenteditable=true element should have its content editable. Meaning the answer to the question you linked is actually invalid (although when it was posted this may have been the case).

Community
  • 1
  • 1
James Donnelly
  • 126,410
  • 34
  • 208
  • 218