Case ce-0159-empty-elements-after-format-remove · Scenario scenario-empty-element-cleanup

Empty elements accumulate after removing formatting in Safari

OS: Windows 11 Device: Desktop or Laptop Any Browser: Safari 17.0 Keyboard: US Status: draft
empty formatting cleanup safari

Phenomenon

When removing formatting (bold, italic, color, etc.) in Safari, empty wrapper elements accumulate in the DOM. These empty elements cause layout issues and bloat the HTML significantly.

Reproduction example

  1. Apply multiple formatting to text
  2. Remove formatting one by one
  3. Observe the DOM structure

Observed behavior

  • Empty <span>, <b>, <i> elements remain
  • Empty elements with style attributes remain
  • DOM becomes heavily bloated
  • Layout has unexpected spacing

Expected behavior

  • Empty elements should be removed
  • DOM should be clean
  • No unnecessary elements should remain
  • Structure should be normalized

Browser Comparison

  • Chrome/Edge: May leave some empty elements
  • Firefox: More likely to leave empty elements
  • Safari: Most likely to accumulate empty elements (this case)

Notes and possible direction for workarounds

  • Implement aggressive cleanup logic
  • Remove all empty formatting elements
  • Normalize DOM structure regularly
  • Clean up after each formatting operation
Before
Hello World
Text with multiple formatting applied
After Removing Formats (Bug)
Hello World
After formatting removal, empty wrapper elements (&lt;b&gt;, &lt;i&gt;, &lt;span&gt;) remain
vs
✅ Expected
Hello World
Expected: Empty elements removed, clean DOM

Browser compatibility matrix

This matrix shows which browser and OS combinations have documented cases for this scenario. The current case is highlighted. Click on a cell to view other cases.

Current case
Confirmed
Draft
No case documented

All variants (detailed table)

Complete list of all cases for this scenario with full environment details.

Case OS Device Browser Keyboard Status
ce-0111-empty-elements-accumulate Windows 11 Desktop or Laptop Any Chrome 120.0 US draft
ce-0127-empty-paragraph-after-delete Windows 11 Desktop or Laptop Any Chrome 120.0 US draft
ce-0140-empty-span-style-attributes Windows 11 Desktop or Laptop Any Chrome 120.0 US draft
ce-0159-empty-elements-after-format-remove Windows 11 Desktop or Laptop Any Safari 17.0 US draft
ce-0174-empty-div-after-list-removal Windows 11 Desktop or Laptop Any Chrome 120.0 US draft

Playground for this case

Use the reported environment as a reference and record what happens in your environment while interacting with the editable area.

Reported environment
OS: Windows 11
Device: Desktop or Laptop Any
Browser: Safari 17.0
Keyboard: US
Your environment
Sample HTML:
Event log
Use this log together with the case description when filing or updating an issue.
0 events
Interact with the editable area to see events here.

Comments & Discussion

Have questions, suggestions, or want to share your experience? Join the discussion below.