Case ce-0140-empty-span-style-attributes · Scenario scenario-empty-element-cleanup

Empty span elements with style attributes accumulate

OS: Windows 11 Device: Desktop or Laptop Any Browser: Chrome 120.0 Keyboard: US Status: draft
empty span style cleanup chrome

Phenomenon

When removing formatting (bold, italic, color, etc.) in Chrome, empty span elements with empty or unnecessary style attributes accumulate in the DOM. These elements bloat the HTML and serve no purpose.

Reproduction example

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

Observed behavior

  • Empty <span style=""> elements remain
  • Or <span> elements with only whitespace remain
  • Style attributes may be empty but still present
  • DOM becomes bloated with empty spans

Expected behavior

  • Empty span elements should be removed
  • Style attributes should be removed when empty
  • DOM should be clean and minimal
  • No unnecessary elements should remain

Browser Comparison

  • Chrome/Edge: Leaves empty spans (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 span elements after formatting removal
  • Remove style attributes if empty
  • Unwrap spans that only contain whitespace
  • Normalize DOM structure regularly
Before
Hello World
Text with multiple formatting applied
After Removing Formats (Bug)
Hello World
After formatting removal, &lt;span&gt; element with empty style attribute remains
vs
✅ Expected
Hello World
Expected: Empty span element and style attribute 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: Chrome 120.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.