#5475·vitepress

Large code block can paint over the following paragraph on initial render

Author: ChisakaKanakoCreated Sep 26, 2026Updated Sep 26, 2026
Labelsbug: pending triage

Describe the bug

On some initial page loads, the bottom of a large code block is painted over the following paragraph. The code block background and the visible horizontal scrollbar cover part of the next line of text.

The issue is intermittent. Waiting briefly, resizing the window, or refreshing the page triggers a repaint and restores the correct spacing.

Reproduction

  1. Open https://vitepress.dev/guide/markdown#advanced-configuration in Safari/WebKit, where the issue has been observed.
  2. Reload the page or navigate directly to the anchor.
  3. Horizontally scroll the large code block.
  4. Occasionally, the bottom of the code block and its horizontal scrollbar paint over the following paragraph.
  5. Wait, resize the window, or refresh the page and the overlap disappears.
Image

Expected behavior

The following paragraph should always remain outside the code block's paint bounds, with the normal vertical margin between the code block and the paragraph. The code block must never cover the paragraph during initial render or after scrolling.

System Info


  System:
    OS: macOS 27.0
    CPU: (10) arm64 Apple M4
    Memory: 87.23 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 26.4.0 - /usr/local/bin/node
    npm: 12.0.2 - /usr/local/bin/npm
    pnpm: 11.24.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 153.0.8010.53
    Safari: 27.0

Additional context

Attached is a screenshot showing the code block background and scrollbar covering the following paragraph.

Current investigation status:

  • The issue has only been observed in Safari/WebKit so far. It is not yet confirmed to be a WebKit bug and has not been tested enough in Chromium to determine whether it is WebKit-specific.
  • The issue is intermittent and has not yet been reproduced reliably in Playwright WebKit.
  • One suspected factor is the code block's nested horizontal scroll containers: the outer div[class*='language-'] and the inner pre. The outer element is also the rounded, painted container.
  • This may be a VitePress CSS/compositing-layer issue, a browser renderer issue, or an interaction between both. More evidence is needed before identifying the responsible layer.
  • A local experiment using overflow: clip and contain: paint on the outer wrapper keeps the inner pre scrollable and preserves the following paragraph's spacing. This is only a candidate fix, not a confirmed solution.
  • No PR has been opened for this issue yet.

Validations