overscroll‑behavior Tester - Online Prevent Pull‑to‑Refresh
Test overscroll‑behavior: contain to prevent background scroll or pull‑to‑refresh. See the effect in a live demo.
UD5 Toolkit
Instantly compare scrollbar-gutter values and visualize layout shift prevention
Welcome! This panel demonstrates scrollbar-gutter in action.
When content grows and a scrollbar appears, the gutter behavior determines whether your layout shifts.
Item AlphaItem BetaItem Gamma
📏 Current content is short — no scrollbar needed.
Welcome! This panel demonstrates scrollbar-gutter in action.
When content grows and a scrollbar appears, the gutter behavior determines whether your layout shifts.
Item AlphaItem BetaItem Gamma
📏 Current content is short — no scrollbar needed.
scrollbar-gutter in CSS?scrollbar-gutter is a CSS property that controls the space (gutter) reserved for the scrollbar. It was introduced in the CSS Overflow Module Level 3 specification. The property allows developers to stabilize the layout by reserving space for the scrollbar even when it's not visible, preventing unwanted layout shifts when the scrollbar appears or disappears. Supported values include auto (default), stable, and stable both-edges.
scrollbar-gutter: stable prevent layout shift?scrollbar-gutter: stable, the browser always reserves the scrollbar's track space, regardless of whether a scrollbar is actually visible. Without it (using auto), the scrollbar appears and disappears dynamically, changing the available content width by approximately 15–17px on Windows. This sudden width change causes text reflow and element repositioning — a major contributor to Cumulative Layout Shift (CLS), which is a Core Web Vital metric. By reserving the space consistently, stable ensures the layout never shifts.
auto and stable?auto (default): The browser decides when to show the gutter. If no scrollbar is needed, no space is reserved. When a scrollbar appears, it takes up space and shrinks the content area — causing layout shift.stable: The gutter space is always reserved, even if the content is short and no scrollbar is needed. The content width remains constant regardless of scrollbar visibility, eliminating layout shift entirely.stable both-edges do?scrollbar-gutter: stable both-edges reserves gutter space on both the left and right edges of the element. This is particularly useful for symmetrical layouts, bidirectional (LTR/RTL) text support, or designs where visual balance is critical. In a left-to-right context, the left gutter is typically unused, but it ensures the layout remains perfectly centered regardless of scrollbar presence on either side.
scrollbar-gutter has no visible effect in the default macOS configuration. To see the effect, go to System Settings → Appearance → Show scroll bars and select "Always". Windows and most Linux distributions show classic scrollbars that occupy space, making the effect immediately visible.
scrollbar-gutter: stable especially valuable — you don't need to guess or hardcode scrollbar widths.
scrollbar-gutter relate to CLS (Cumulative Layout Shift)?scrollbar-gutter: stable on the <html> or <body> element prevents this, helping achieve a CLS score of 0.
scrollbar-gutter with overflow: hidden?scrollbar-gutter: stable works even with overflow: hidden. The gutter space is reserved regardless of the overflow setting, ensuring that if you dynamically change overflow (e.g., opening a modal that locks body scroll), the layout doesn't shift. This is a common pattern: html { scrollbar-gutter: stable; } combined with body.overflow-hidden when modals are open.
scrollbar-gutter?scrollbar-gutter is supported in all modern browsers:
both-edges may have limited support)auto behavior).
scrollbar-gutter globally to prevent layout shifts?html {
scrollbar-gutter: stable;
}
This ensures the gutter is reserved across all pages. Some developers also apply it to specific scrollable containers (sidebars, modals, etc.) where internal layout stability is critical. Note: if your design uses a fixed header with overflow-y: auto on the body, apply it to the scrolling container instead.
scrollbar-gutter and the old overflow: overlay?overflow: overlay (deprecated, removed from the spec) made scrollbars appear as overlays without taking layout space — the opposite goal of scrollbar-gutter: stable. While overlay prevented layout shifts by never reserving space (always overlaying), it caused content to be hidden behind scrollbars. scrollbar-gutter: stable takes the better approach: always reserving space so content is never obscured and layout never shifts. overflow: overlay should not be used in modern projects.
function getScrollbarWidth() {
const el = document.createElement('div');
el.style.cssText = 'overflow:scroll;visibility:hidden;position:absolute;width:100px;';
document.body.appendChild(el);
const w = el.offsetWidth - el.clientWidth;
el.remove();
return w; // Typically 0 or 15-17
}
This tool automatically runs this detection on page load and displays the result.
Test overscroll‑behavior: contain to prevent background scroll or pull‑to‑refresh. See the effect in a live demo.
Toggle scroll‑behavior: smooth and click anchor links to see the scrolling animation. Implement modern UX.
Use CSS masks and fixed backgrounds to create a unique parallax reveal effect. Copy the code. No JavaScript.
Compare break‑all, keep‑all, and overflow‑wrap: anywhere/break‑word. Paste long words and see how they wrap.
Create vertically oriented text layouts with `writing‑mode`. See the effect and copy the complete CSS. For vertical languages.
See the difference between clone and slice on inline boxes that break across lines. Useful for multi‑line headings.
Create an animation that advances with scroll using animation‑timeline: scroll(). See the visual timeline editor. Modern CSS.
Paste your full CSS and HTML; automatically identify and extract the styles needed for the visible part. Reduce render‑blocking resources.
Test different line‑break and word‑break values on Chinese/Japanese/Korean text. See how browsers wrap. Essential for i18n.
Use named grid lines instead of column numbers. See how they simplify placement. Visual, interactive learning.
Create a customizable scrolling marquee banner. Copy the HTML and CSS. For retro web projects or fun.
Apply content‑visibility: auto to off‑screen sections and see the rendering cost drop. Demos for infinite scroll optimization.
Animate elements as they enter and exit the viewport using view() timeline. Parallax and reveal effects without JS.
Nest elements in 3D space with preserve‑3d vs flat. Rotate the parent and see children behave differently.
Apply dyslexia‑friendly fonts, spacing, and background to any text. Preview and copy the formatted version. Improve readability.
Stack multiple background images and blend them with colors. Create unique textures. Copy the CSS code instantly.
Build a complete font‑stack for your website. Choose a primary font and get the best fallback options for different OS. Copy the CSS.
New CSS text‑spacing property for fine control over punctuation spacing. See the effect live. For advanced typography.
Paste HTML and see the order in which elements would receive focus via Tab key. Highlight issues. Local accessibility testing.
Style a drop cap using the initial‑letter property. Set size and sink. Modern alternative to pseudo‑element hacks.
Style a drop cap using the initial‑letter property. Set size and sink. Modern alternative to pseudo‑element hacks.
Enter a URL and see a visual map of the tab order. Detect broken tabindex values. Improve keyboard navigation.
See how grid-auto-flow: row vs column changes item placement. Add and remove items to understand the algorithm. Visual.
Paste a website's HTML and see which text is only visible to screen readers (e.g., .sr‑only). Preview the accessible layer.
Simulate reduced motion preference and test your animations. Copy the media query snippet. Keep your users safe.
Paste HTML and see a collapsible tree of tags. Understand document outline and nesting. Handier than raw code.
See which fonts map to generic families (serif, sans‑serif, monospace) on different operating systems. A handy reference.
Enter a URL and extract tab‐index order violations and focusable elements. Quick accessibility audit. Client‑side fetch.
Create a repeating text pattern from a short string for watermarking documents or images. Download SVG pattern.
Enter a URL and get a quick simulation of First Contentful Paint, LCP, and CLS using browser metrics. Lightweight alternative.