Scenario

Blockquote editing behavior varies across browsers

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.

formatting
Scenario ID
scenario-blockquote-behavior

Details

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.

Observed Behavior

Scenario 1: Pressing Enter in a blockquote

  • Chrome/Edge: Creates a new paragraph within the blockquote
  • Firefox: May create new paragraph or break blockquote structure
  • Safari: Behavior varies, may create nested blockquotes

Scenario 2: Applying formatting in blockquote

  • Chrome/Edge: Formatting is applied, but may break structure
  • Firefox: May break blockquote structure when formatting
  • Safari: Most likely to break structure

Scenario 3: Pasting content into blockquote

  • Chrome/Edge: May preserve blockquote or break it
  • Firefox: More likely to break blockquote structure
  • Safari: May create unexpected nested structures

Scenario 4: Exiting blockquote

  • Chrome/Edge: May require multiple Enter presses or manual exit
  • Firefox: Similar behavior
  • Safari: Exiting behavior inconsistent

Impact

  • Difficulty maintaining blockquote structure
  • Unexpected nested blockquotes
  • Structure breaks during editing
  • Poor user experience when working with quotes

Browser Comparison

  • Chrome/Edge: Generally better blockquote handling
  • Firefox: More likely to break structure
  • Safari: Most inconsistent behavior

Workaround

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));
  }
});

References

Scenario flow

Visual view of how this scenario connects to its concrete cases and environments. Nodes can be dragged and clicked.

React Flow mini map

Variants

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

Browser compatibility

This matrix shows which browser and OS combinations have documented cases for this scenario. Click on a cell to view the specific case.

Confirmed
Draft
No case documented

Cases

Open a case to see the detailed description and its dedicated playground.

Related Scenarios

Other scenarios that share similar tags or category.

Tags: structure

Empty elements accumulate in DOM during editing

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.

5 cases
Tags: structure

Nested formatting elements create complex DOM structures

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.

3 cases
Tags: indentation

Nested list editing behavior is 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.

3 cases
Category: formatting

Background color changes behave inconsistently

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.

3 cases
Category: formatting

Browser auto-formatting interferes with contenteditable editing

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.

0 cases

Comments & Discussion

Have questions, suggestions, or want to share your experience? Join the discussion below.