Open Bug 205946 Opened 18 years ago Updated 3 years ago

Get rid of annoying useless trailing <br> generated by editor in text and paragraphs


(Core :: DOM: Editor, defect, P3)





(Reporter: glazou, Unassigned)


(Blocks 4 open bugs)


(Whiteboard: composer++)


(2 obsolete files)

Test case #1 :

1. launch composer
2. type aaaaaa
3. CR
4. type bbbbbb
5. switch to source view

Expected result:      aaaaaa<br>
Actual result:        aaaaaa<br>

Test case #2

1. launch composer
2. select Format > Paragraph
3. type aaaaaa
4. CR
5. type bbbbbb
6. switch to source view

Expected result:      <p>aaaaaa<br>
Actual result:        <p>aaaaaa<br>
Attached patch fix #1 (obsolete) — Splinter Review
Comment on attachment 123509 [details] [diff] [review]
fix #1

jfrancis, can you r= please ?
peter, can you sr= please ?
Attachment #123509 - Flags: superreview?(peterv)
Attachment #123509 - Flags: review?(jfrancis)
Priority: -- → P2
Whiteboard: composer++
Target Milestone: --- → mozilla1.5alpha
Attached patch fix #2 (obsolete) — Splinter Review
previous patch was buggy, getting rid of the <br> even in the case described in

the comment in
Attachment #123509 - Attachment is obsolete: true
Comment on attachment 124263 [details] [diff] [review]
fix #2

Joe, please, can you r= this patch ?
Attachment #124263 - Flags: review?(jfrancis)
Please describe to me exactly what these two changes do.  They can't fix this
bug, since this bug is not a but at all, as per the comment in

This may not strictly be a bug according to the comments, but it's definitely a
bit of a kludge designed to support an antiquated typographical technique, and
looks buggy when you view the code generated by Composer. Isn't there a cleaner
way to achieve this? Rather than sprinkling a lot of unnecessary <br> tags
throughout every piece of generated code just because some users like two spaces
at the end of sentences.

Currently it's a case of swapping one bug for another, where both really need to
be resolved.
Joe, the patch (a) removes a trailing non visible <br> if the last char of the
preceeding text node is not a white space (b) removed the trailing <br> in a
paragraph when enter is pressed twice.
I downloaded 2003-may-27 build. Thanks for fix

1) Still I get a <br> inside <body> of a new document.

-------- new html document in composer begins -----
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
<body style="background-image: url(about:blank);">
-------- new html document in composer ends -----

2) A <br> will be created in a empty tag


will be changed as 

read comment

It seems extra <br> is not a bug, but a feature
What if user dont want 2 spaces at the end of a sentence. 
Cant we have a preference setting to enable disable 2 spaces and extra <br>

Also why <br> cant we have <br/> instead
Attachment #123509 - Flags: superreview?(peterv)
Attachment #123509 - Flags: review?(mozeditor)
Comment on attachment 124263 [details] [diff] [review]
fix #2

this is buggy and obsolete
Attachment #124263 - Attachment is obsolete: true
<br /> is preferable per recommendations for compatibility
with existing user agents in W3C XHTML spec.  
Depends on: 240933
Let me clarify my earlier post. It may have been misunderstood:

<br /> is better than <br/> per recommendations cited above.

However, it is best to avoid the extra <br/> elements in the first place.
In fact, <p>...</p> is often more appropriate than <br />.
*** Bug 255839 has been marked as a duplicate of this bug. ***
Blocks: 334258
Blocks: 365257
Blocks: 255166
QA Contact: bugzilla → editor
Assignee: daniel → nobody
Flags: wanted1.9.2?
Target Milestone: mozilla1.5alpha → ---
Attachment #124263 - Flags: review?(mozeditor)
Flags: wanted1.9.2?
Flags: wanted1.9.2-
Flags: blocking1.9.2-
Blocks: 253185
Is there a workaround, please? I need to obtain the exact content of contentEditable (white-space: pre-wrap) on input and have no idea how to identify the trailing <br> as desired or not (to remove it potentially).

Take innerHTML, remove trailing <br> and put it to an element of the exact size and formatting. If the copy is NOT lower, the original <br> should be removed. In my use case this might be reliable, but the performance could be a problem.
Moving to p3 because no activity for at least 1 year(s).
See for more information
Priority: P2 → P3
Maybe the requirement can be even closed -- in FF 60, bug 1430551 was implemented and <br> should be replaced by <div> now.
You need to log in before you can comment on or make changes to this bug.