Phenomenon
When removing a link (keeping the text) in Firefox, empty anchor tags may be left in the DOM. These empty <a> elements cause layout issues and bloat the HTML.
Reproduction example
- Create a link:
<a href="url">Link text</a> - Remove the link (unlink operation)
- Observe the DOM
Observed behavior
- Empty
<a></a>tags may remain - Or
<a>tags with only whitespace remain - DOM becomes bloated
- Layout may have unexpected spacing
Expected behavior
- Link should be removed cleanly
- Text should remain without link wrapper
- No empty anchor tags should remain
- DOM should be clean
Browser Comparison
- Chrome/Edge: May leave empty anchors
- Firefox: More likely to leave empty anchors (this case)
- Safari: Most likely to leave empty structures
Notes and possible direction for workarounds
- Intercept link removal
- Clean up empty anchor tags
- Unwrap link and preserve text content
- Normalize DOM after link operations