Firefox does not allow empty content area

Firefox version 30.

The following code works fine in chrome, and I can start typing in the paragraph.

But this does not work in firefox, any hints what is wrong.

<div>
    <div>
      <span contenteditable="false">Not editable area</span>
        <p contenteditable="true"></p>
    </div>
</div>

JSFiddle - http://jsfiddle.net/THPmr/30/

+4
source share
2 answers

Chrome seems to automatically assign some height to the content paragraph, but Firefox doesn't. A simple solution is to add a minimum height to the paragraph.

<p contenteditable="true" style="min-height:15px"></p>

Now we don’t need to worry about extra spaces and unnecessary br tags

+7
source

CSS solution:

p[contenteditable] { min-height: 1em}
/* or more generic for any element*/
[contenteditable] { min-height: 1em}

DEMO

+1
source

Source: https://habr.com/ru/post/1548710/


All Articles