Pressing Enter in blockquote may create nested blockquotes in Safari
OS: macOS 14.0 · Device: Desktop or Laptop Any · Browser: Safari 17.0 · Keyboard: US
Open case →Scenario
Editing text within blockquote elements in contenteditable behaves inconsistently across browsers. Pressing Enter, applying formatting, or pasting content may break the blockquote structure, create nested blockquotes, or behave unexpectedly.
Editing text within blockquote elements in contenteditable behaves inconsistently across browsers. Pressing Enter, applying formatting, or pasting content may break the blockquote structure, create nested blockquotes, or behave unexpectedly.
Implement custom blockquote handling:
element.addEventListener('beforeinput', (e) => {
if (e.inputType === 'insertParagraph') {
const selection = window.getSelection();
if (selection.rangeCount === 0) return;
const range = selection.getRangeAt(0);
const blockquote = range.startContainer.closest('blockquote');
if (blockquote) {
e.preventDefault();
// Create new paragraph within blockquote
const p = document.createElement('p');
const br = document.createElement('br');
p.appendChild(br);
range.deleteContents();
range.insertNode(p);
range.setStartBefore(br);
range.collapse(true);
selection.removeAllRanges();
selection.addRange(range);
}
}
});
// Prevent breaking blockquote structure when pasting
element.addEventListener('paste', (e) => {
const selection = window.getSelection();
if (selection.rangeCount === 0) return;
const range = selection.getRangeAt(0);
const blockquote = range.startContainer.closest('blockquote');
if (blockquote) {
e.preventDefault();
const html = e.clipboardData.getData('text/html');
const text = e.clipboardData.getData('text/plain');
// Strip blockquote tags from pasted content to avoid nesting
const temp = document.createElement('div');
temp.innerHTML = html;
const blockquotes = temp.querySelectorAll('blockquote');
blockquotes.forEach(bq => {
const parent = bq.parentNode;
while (bq.firstChild) {
parent.insertBefore(bq.firstChild, bq);
}
parent.removeChild(bq);
});
range.deleteContents();
range.insertNode(document.createRange().createContextualFragment(temp.innerHTML));
}
});
Visual view of how this scenario connects to its concrete cases and environments. Nodes can be dragged and clicked.
Each row is a concrete case for this scenario, with a dedicated document and playground.
| Case | OS | Device | Browser | Keyboard | Status |
|---|---|---|---|---|---|
| ce-0107-blockquote-enter-safari | macOS 14.0 | Desktop or Laptop Any | Safari 17.0 | US | draft |
| ce-0137-blockquote-exit-difficult | Windows 11 | Desktop or Laptop Any | Chrome 120.0 | US | draft |
| ce-0156-blockquote-nested-on-paste | Windows 11 | Desktop or Laptop Any | Safari 17.0 | US | draft |
| ce-0169-blockquote-formatting-breaks | Windows 11 | Desktop or Laptop Any | Firefox 120.0 | US | draft |
This matrix shows which browser and OS combinations have documented cases for this scenario. Click on a cell to view the specific case.
| Browser | Windows | macOS |
|---|---|---|
| Chrome | — | |
| Firefox | — | |
| Safari |
Open a case to see the detailed description and its dedicated playground.
OS: macOS 14.0 · Device: Desktop or Laptop Any · Browser: Safari 17.0 · Keyboard: US
Open case →OS: Windows 11 · Device: Desktop or Laptop Any · Browser: Chrome 120.0 · Keyboard: US
Open case →OS: Windows 11 · Device: Desktop or Laptop Any · Browser: Safari 17.0 · Keyboard: US
Open case →OS: Windows 11 · Device: Desktop or Laptop Any · Browser: Firefox 120.0 · Keyboard: US
Open case →Other scenarios that share similar tags or category.
During editing operations, empty elements (empty paragraphs, divs, spans with no content) accumulate in the DOM. These elements can cause layout issues, make the HTML bloated, and create unexpected behavior. Browsers handle empty element cleanup inconsistently.
Applying multiple formatting operations (bold, italic, underline, etc.) creates nested HTML elements that can become complex and hard to manage. Browsers handle nested formatting differently, and the resulting DOM structure can be inconsistent.
When editing nested lists (lists within list items), the behavior of Enter, Backspace, Delete, and Tab keys varies significantly across browsers. Creating, editing, and deleting nested list items can result in unexpected DOM structures or lost formatting.
Changing background color (highlighting) in contenteditable elements behaves inconsistently across browsers. Background colors may be applied as inline styles, may not persist when typing, or may interfere with text selection. The behavior differs from text color changes.
Browsers may automatically format text in contenteditable elements, such as converting URLs to links, capitalizing text, formatting numbers, or applying other transformations. This auto-formatting can interfere with editing, cause cursor positioning issues, and create unwanted markup or style changes.
Have questions, suggestions, or want to share your experience? Join the discussion below.