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

Markus Ernst derernst at gmx.ch
Mon May 16 07:08:08 PDT 2011


Am 16.05.2011 15:33 schrieb Markus Ernst:
> Am 12.05.2011 22:28 schrieb Aryeh Gregor:
>> A problem with<p> is that it has top and bottom margins by default,
>> so hitting Enter once will look like a double line break. One
>> real-world execCommand() user I looked at (vBulletin) sets p { margin:
>> 0 } for its rich-text editor for this reason, and translates<p> and
>> <div> to line breaks on the server side. The usual convention in text
>> editors is that hitting Enter only creates one line break, although
>> Word 2007 seems to do two by default.

I am sorry I overread this last sentence when writing my previous 
message. I have a swiss-german installation of Word 2007, I did not 
change the settings. Hitting enter produces paragraphs here, and applies 
the spaces above and/or below that are specified in the paragraph style. 
This is the behaviour I have known from Word for years. Maybe there are 
regional differences in the defaults of Word.

> This is very presentational thinking.

Re-reading my message I am afraid this sentence could be read as an 
offense. There was absolutely no offense intended (I am sorry I had to 
go pick up my daughter and sent too quickly). I wanted to state that 
what CSS people apply should not matter to the question of creating <p>, 
<div> or <br>.

The vBulletin example shows that there is a use case for applying <br>. 
I state that there is a use case for applying <p> for enter and <br> for 
shift-enter.

IMO an ideal solution would provide both (or, if there are use cases for 
<div>, all three) possibilities, settable with a flag or an attribute. 
The standard should be what office users expect from their everyday 
experience.



More information about the whatwg mailing list