0

As you can see, at least on Chrome, the contentEditable attribute seems to be ignored on textarea.

Question A: Is that how it's supposed to work?

Question C: Does using contentEditable on a textarea have any consequences other than proving you're an idiot?

Question D: Why is there no question B? Just kidding, I had a clown for breakfast today. :D

textarea { /* not relevant for the question, only for the demo */
  display: block;
  width: 500px;
}
<textarea contentEditable="true">contentEditable="true"</textarea>
<textarea contentEditable="false">contentEditable="false"</textarea>
<textarea contentEditable="true" readonly>contentEditable="true" readonly</textarea>
<textarea contentEditable="true" disabled>contentEditable="true" disabled</textarea>
connexo
  • 53,704
  • 14
  • 91
  • 128

1 Answers1

2

contentEditable has no effect and on textarea, the HTML5 spec is mute about the subject.

contentEditable=false allows to make an element not editable inside another element which is contentEditable=true. The default behavior is to inherit the value of contentEditable so that every children of an editable element is also editable.

You can still delete the non-editable element but not edit it. This is demonstrated in the following snippet.

textarea { /* not relevant for the question, only for the demo */
  display: block;
  width: 500px;
}
<div contentEditable="true">
    <span>Editable span</span> but
    <span contentEditable="false">This one is not</span>
</textarea>
amirouche
  • 7,682
  • 6
  • 40
  • 94