Case ce-0168-enter-creates-p-firefox · Scenario scenario-line-break-element-type

Enter key creates paragraph elements in Firefox

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

Phenomenon

When pressing Enter in a contenteditable element in Firefox, a new <p> paragraph element is created instead of a <div>. This differs from Chrome which creates <div> 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 <p> element is created (e.g., <p><br></p>)
  • Chrome creates <div> elements instead
  • CSS default margins differ between <p> and <div>
  • 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
  • DOM structure should be normalized

Browser Comparison

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

Notes and possible direction for workarounds

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


Enter key creates &lt;p&gt; element (Firefox)
vs
✅ Expected
Hello

Expected: Consistent element type used (or selectable)

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: Firefox 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.