Case ce-0162-html-entities-serialization · Scenario scenario-html-entity-encoding

HTML entities are encoded inconsistently when serializing

OS: Windows 11 Device: Desktop or Laptop Any Browser: Chrome 120.0 Keyboard: US Status: draft
html entity encoding serialization chrome

Phenomenon

When serializing contenteditable content (e.g., using innerHTML) in Chrome, special characters may be encoded as HTML entities or kept as actual characters inconsistently. This makes it difficult to predict the output format.

Reproduction example

  1. Insert text with special characters: <div>Test</div>
  2. Serialize using element.innerHTML
  3. Observe the output

Observed behavior

  • Characters may be encoded: &lt;div&gt;Test&lt;/div&gt;
  • Or characters may be kept as-is: <div>Test</div>
  • Encoding is inconsistent
  • Output format is unpredictable

Expected behavior

  • Entity encoding should be consistent
  • Or encoding should be predictable
  • Special characters should be handled correctly
  • Output format should be reliable

Browser Comparison

  • Chrome/Edge: Encoding inconsistent (this case)
  • Firefox: Similar encoding inconsistency
  • Safari: Encoding behavior varies

Notes and possible direction for workarounds

  • Normalize entity encoding after serialization
  • Use consistent encoding strategy
  • Document expected encoding behavior
  • Handle special characters explicitly
Before
Test
Content with special characters
After innerHTML (Bug - Encoded)
<div>Test</div>
When serializing, encoded as HTML entities
vs
✅ Expected
Test
Expected: Consistent encoding handling

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-0123-html-entities-paste Windows 11 Desktop or Laptop Any Chrome 120.0 US draft
ce-0132-html-entities-copy Windows 11 Desktop or Laptop Any Chrome 120.0 US draft
ce-0162-html-entities-serialization 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.