Case ce-0100-link-insertion-chrome · Scenario scenario-link-insertion

Creating link from selected text works but may create nested links in Chrome

OS: Windows 11 Device: Desktop or Laptop Any Browser: Chrome 120.0 Keyboard: US Status: draft
link anchor nested chrome

Phenomenon

When creating a link from selected text in Chrome, the link is created successfully, but if the selection is already inside a link, nested links may be created, which is invalid HTML.

Reproduction example

  1. Create a link: <a href="url1">Link text</a>
  2. Select part of “Link text”
  3. Create a new link (Ctrl+K or programmatically)

Observed behavior

  • A nested link structure may be created: <a href="url1"><a href="url2">Link text</a></a>
  • This is invalid HTML (links cannot be nested)
  • Browser may render it incorrectly
  • DOM structure becomes malformed

Expected behavior

  • Existing link should be removed first
  • New link should replace the old one
  • No nested links should be created
  • HTML structure should remain valid

Browser Comparison

  • Chrome/Edge: May create nested links (this case)
  • Firefox: More likely to create nested links
  • Safari: May create unexpected structures

Notes and possible direction for workarounds

  • Check if selection is inside an existing link before creating new one
  • Remove existing link structure first
  • Use closest('a') to find parent link
  • Unwrap existing link before creating new one
Before
Existing link
After New Link (Bug)
Nested link created (invalid HTML)
vs
✅ Expected
Expected: Existing link removed then new link created

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-0100-link-insertion-chrome Windows 11 Desktop or Laptop Any Chrome 120.0 US draft
ce-0133-link-removal-leaves-empty Windows 11 Desktop or Laptop Any Firefox 120.0 US draft
ce-0152-link-href-update-difficult 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.