W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2011

[whatwg] Pressing Enter in contenteditable: <p> or <br> or <div>?

From: Ryosuke Niwa <rniwa@webkit.org>
Date: Fri, 13 May 2011 10:48:51 -0700
Message-ID: <BANLkTikMam8XYF=V8dx0zTkEh0sfMzEsEw@mail.gmail.com>
On Fri, May 13, 2011 at 10:26 AM, Aryeh Gregor <Simetrical+w3c at gmail.com>wrote:
>
> I'm not completely decided at this point, but am now leaning toward
> <br>.  Currently my spec uses <br> where some type of break is needed
> (e.g., de-indenting an inline node when that would make it the sibling
> of some other inline node), because that's the shortest markup in
> simple cases.
>

Note that br and div affect UBA differently so we must consider what
bidirectional text users want as well.

For example, if we had <div dir="rtl">hello</div>, and inserted br as in
<div dir="rtl">hello<br></div>, then we preserve the RTL directionality.  If
we insert div on the other hand, <div dir="rtl">hello</div><div></div>, then
new paragraph will have the containing block's direction.

This will be a tricky issue when people want to mix LTR/RTL paragraphs in
the same editable region.

I guess I'm leaning toward using <br> by default.  If any
> implementers feel strongly, now would be a good time to speak up.


I strongly feel that we should default to div for the backward
compatibility.  And this is the preferred paragraph separator in many Google
products as far as I know because div allows developers to easy apply style,
add class, etc... to a paragraph.  And there seems to be a long history of
browsers inserting inserting p/div on Enter and inserting br on Shift+Enter
(on Windows), and changing that behavior will confuse users who are used to
this behavior.

- Ryosuke
Received on Friday, 13 May 2011 10:48:51 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:33 UTC