Case ce-0018 · Scenario scenario-execCommand-alternatives

execCommand is deprecated but still widely used for formatting

OS: Any Ubuntu 22.04 Device: Desktop or Laptop Any Browser: Chrome 120.0 Keyboard: US Status: draft
execCommand formatting deprecation chrome

Phenomenon

The document.execCommand() API, which is commonly used to apply formatting (bold, italic, etc.) in contenteditable regions, has been deprecated. However, there is no complete replacement, and many implementations still rely on it. This creates uncertainty about future browser support.

Reproduction example

  1. Create a contenteditable div.
  2. Use document.execCommand('bold', false, null) to apply bold formatting.
  3. Check browser console for deprecation warnings.
  4. Observe that the command still works but shows warnings.

Observed behavior

  • Chrome shows deprecation warnings in the console when using execCommand.
  • The commands still function but may stop working in future browser versions.
  • The alternative (Selection API + DOM manipulation) is more complex to implement.

Expected behavior

  • A standardized, modern API should be available for formatting contenteditable regions.
  • The new API should be well-documented and supported across browsers.
  • Migration path from execCommand should be clear.

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: Any Ubuntu 22.04
Device: Desktop or Laptop Any
Browser: Chrome 120.0
Keyboard: US
Your environment

Use this editable area to reproduce the described case.

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.