Phenomenon
When deleting all text from a paragraph in Chrome, empty paragraph elements with only <br> tags accumulate in the DOM. These empty paragraphs cause unnecessary spacing and bloat the HTML.
Reproduction example
- Create multiple paragraphs with text
- Delete all text from each paragraph
- Observe the DOM structure
Observed behavior
- Empty
<p><br></p>elements remain - Multiple empty paragraphs accumulate
- DOM becomes bloated
- Unnecessary spacing appears
Expected behavior
- Empty paragraphs should be cleaned up
- Or at least one empty paragraph should remain for cursor
- DOM should be minimal
- No unnecessary spacing
Browser Comparison
- Chrome/Edge: Leaves empty paragraphs (this case)
- Firefox: More likely to leave empty elements
- Safari: Most likely to accumulate empty elements
Notes and possible direction for workarounds
- Clean up empty paragraphs after deletion
- Keep only one empty paragraph for cursor placement
- Remove empty paragraphs that are not needed
- Normalize DOM structure regularly