Case ce-0104-enter-creates-div-chrome · Scenario scenario-line-break-element-type

Enter key creates div elements instead of paragraphs in Chrome

OS: Windows 11 Device: Desktop or Laptop Any Browser: Chrome 120.0 Keyboard: US Status: draft
line-break div paragraph chrome

Phenomenon

When pressing Enter in a contenteditable element in Chrome, a new <div> element is created instead of a <p> paragraph. This differs from Firefox which creates <p> elements, and can cause CSS styling differences.

Reproduction example

  1. Focus a contenteditable element
  2. Type some text
  3. Press Enter

Observed behavior

  • A new <div> element is created (e.g., <div><br></div>)
  • Firefox creates <p> elements instead
  • CSS default margins differ between <div> and <p>
  • DOM structure is inconsistent across browsers

Expected behavior

  • Either <div> or <p> should be used consistently
  • Or behavior should be configurable
  • CSS styling should account for element type differences

Browser Comparison

  • Chrome/Edge: Creates <div> elements (this case)
  • Firefox: Creates <p> elements
  • Safari: May create <div>, <p>, or <br> depending on context

Notes and possible direction for workarounds

  • Normalize DOM structure after Enter key
  • Convert all <div> elements to <p> for consistency
  • Or convert all <p> to <div> to match Chrome
  • Use CSS to normalize margins regardless of element type
Before
Hello
Basic text
→
After Enter (Bug)
Hello

Enter creates &lt;div&gt; element (Firefox uses &lt;p&gt;)
vs
✅ Expected (Normalized)

Hello

Expected: Consistent element type used (all &lt;p&gt; or all &lt;div&gt;)

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-0104-enter-creates-div-chrome Windows 11 Desktop or Laptop Any Chrome 120.0 US draft
ce-0168-enter-creates-p-firefox Windows 11 Desktop or Laptop Any Firefox 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.