Caso ce-0003 · Escenario scenario-double-line-break

Pressing Enter inserts two line breaks in contenteditable

SO: macOS 14.0 Dispositivo: Laptop MacBook Pro Navegador: Safari 17.0 Teclado: US Borrador
enternewline

Esta página aún no ha sido traducida

Actualmente se muestra el contenido original en inglés. Agradecemos su contribución a la traducción.

Phenomenon

In a plain contenteditable element, pressing Enter inserts two visible line breaks instead of one. The resulting DOM contains nested <div> or <br> elements that render as an extra blank line.

Reproduction example

  1. Focus the editable area.
  2. Type a short word on the first line.
  3. Press Enter once.
  4. Type another word on what appears to be the second line.

Observed behavior

  • The visual gap between the lines is larger than a single line height.
  • Inspecting the DOM shows two consecutive block-level containers or a sequence of <br> elements that corresponds to two line breaks.

Expected behavior

  • Pressing Enter once inserts a single paragraph break.

Notes and possible direction for workarounds

  • Check whether the browser uses <div>, <p>, or <br> to represent paragraph breaks in this configuration.
  • Adjust CSS line-height and margins to verify whether the effect comes from DOM structure or styling.
  • For products that must normalize the markup, consider translating the native structure into a controlled model (for example, a single <p> per line) before storing or diffing the content.

Variantes de este escenario

Caso SO Navegador Estado
ce-0003 macOS 14.0 Safari 17.0 Borrador
ce-0023 macOS Ubuntu 22.04 Chrome 120.0 Borrador

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: macOS 14.0
Device: Laptop MacBook Pro
Browser: Safari 17.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.