I have a div
<div contentEditable="true">
<h1> My headline</h1>
</div>
If i am editing the text inside the <h1>
tag, and press return, it adds a new div under, instead of the normal paragraph tag it usually inserts when entering return
Making it:
<div contentEditable="true">
<h1> My headline edited</h1>
<div> i tapped return</div>
</div>
What i really want is
<div contentEditable="true">
<h1> My headline edited</h1>
<p> i tapped return</p>
<p> return again</p>
</div>
Whats strange is that usually when you write somewhere and press return it adds a new <p>
, but just not when editing <h1>
. Is it possible to fix this with Javascript/Jquery/Html5?
I am using Safari on an iOS-device
`, but just not when editing `
`" This is because h1...h6 elements aren't supposed to contain `
` tags; according to the HTML spec they can only contain "Phrasing content" which is these tags only: https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
– Daniel Beck May 20 '17 at 20:45