[whatwg] Pressing Enter in contenteditable: <p> or <br> or <div>?
derernst at gmx.ch
Tue May 17 00:26:59 PDT 2011
Am 13.05.2011 12:00 schrieb Michael A. Puls II:
> On Thu, 12 May 2011 16:28:47 -0400, Aryeh Gregor
> <Simetrical+w3c at gmail.com> wrote:
>> Another problem with <p> is that it's very easy to create
>> unserializable DOMs with it. I've seen cases where at least some
>> browsers will put things inside <p> that will break out of the <p>,
>> and I've done it myself by mistake too.
> I think the browser/editor just shouldn't allow that in this case. (Not
> saying that it's easy to enforce it though.)
As an author or CMS implementor I'd be happy to see UAs solve this for
me, creating a valid sequence of paragraphs.
OTOH, if you use <div>s in order to keep the output serializable, this
might lead to kind of messy code.
Imagine a content of the contenteditable element like:
The user puts the caret to the end of the first line and clicks Enter.
With a strict <p>/<br> behavior, this is a well-defined action, adding a
new paragraph resp. inserting a newline. But if you go with <div>s, this
will possibly mess up the code in a way that is hard to fix (though it
is valid and serializable HTML).
More information about the whatwg