The scroll-behavior property controls whether scrolling is instant or animated. With one line of CSS you can make anchor links and in-page navigation feel smoother and more polished.
01
auto
Instant jump scroll.
02
smooth
Animated scroll.
03
html
Page-wide effect.
04
overflow
Container scroll.
05
anchors
#section links.
06
a11y
Reduced motion.
Fundamentals
Introduction
The scroll-behavior property in CSS is used to control the scrolling behavior for a webpage.
This property specifies whether to use smooth scrolling or instant scrolling when a user navigates through internal links within a document or when a script calls for scrolling. Smooth scrolling provides a visually appealing and user-friendly experience, especially for single-page applications and websites with long content.
Definition and Usage
scroll-behavior applies to scroll containers — most commonly the root html element for the whole page, or any element with overflow: auto or overflow: scroll.
When set to smooth, clicking an anchor link such as <a href="#section"> scrolls gradually to the target instead of jumping instantly.
💡
Beginner Tip
Start with html { scroll-behavior: smooth; } on documentation pages and landing pages with section navigation.
Foundation
📝 Syntax
The syntax for the scroll-behavior property is simple. It can be applied to the html element to affect the entire document, or to any scrollable container.
syntax.css
element{scroll-behavior:auto|smooth;}
Basic Example
smooth-page.css
html{scroll-behavior:smooth;}
Syntax Rules
Only two keyword values are valid: auto and smooth.
Apply to html for document-level scrolling.
Apply to a scroll container for scrolling inside that element.
Works with anchor links, focus moves, and many programmatic scroll APIs.
Does not expose custom duration or easing in pure CSS.
Defaults
🎯 Default Value
The default value of the scroll-behavior property is auto, which provides an instant scrolling effect.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Default value
auto
Smooth page scroll
html { scroll-behavior: smooth; }
Valid values
auto, smooth
Applies to
Scroll containers
Inherited
No
Animatable
No
Reference
💎 Property Values
Value
Example
Description
auto
scroll-behavior: auto;
Instant scrolling with no animation. This is the default browser behavior.
smooth
scroll-behavior: smooth;
Animated scrolling that gradually moves to the target position.
autosmooth
Context
When to Use scroll-behavior
scroll-behavior is the right tool when in-page navigation should feel gentler:
Anchor navigation — Smoothly scroll between sections linked with #id hashes.
Back-to-top links — Provide a softer return to the page header.
The page returns smoothly to the header when the link is clicked.
How It Works
Pair smooth scrolling with a visible fixed action so long articles stay easy to navigate.
Companion
scroll-behavior with scroll-margin
Smooth scrolling looks best when the destination is fully visible. Fixed headers often cover linked sections. Use scroll-margin on targets so they stop below sticky navigation.
An anchor link, keyboard focus change, or script requests a new scroll position.
Trigger
2
Browser checks the container
The nearest scroll container’s scroll-behavior value is read.
auto | smooth
3
Scroll position updates
auto jumps instantly; smooth animates over a short browser-defined duration.
Motion
=
★
Polished navigation
In-page links feel intentional and easier to follow on long content.
Compatibility
Browser Compatibility
The scroll-behavior property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Edge, and Safari. Test anchor navigation on your target browsers and devices.
✓ Scrolling · Modern support
Reliable smooth-scroll support
Current Chrome, Firefox, Safari, Edge, and Opera support scroll-behavior: smooth.
97%Modern browser support
Google Chrome61+ · Desktop & Mobile
Full support
Mozilla Firefox36+ · Desktop & Mobile
Full support
Apple Safari15.4+ · macOS & iOS
Full support
Microsoft Edge79+ · Chromium
Full support
Opera48+ · Modern versions
Full support
Testing tip
Users with prefers-reduced-motion: reduce may prefer instant scrolling. Provide an auto fallback in a media query.
scroll-behavior property97% supported
Bottom line:scroll-behavior: smooth is safe for modern projects; test sticky headers with scroll-margin.
Wrap Up
Conclusion
The scroll-behavior property is a useful tool for enhancing user experience by providing smooth scrolling effects on your website.
By applying this property, you can make navigating long pages or single-page applications more visually appealing and user-friendly. Experiment with this property to see how it can improve the navigation and overall feel of your web projects.
Use these points when building in-page navigation.
5
Core concepts
★01
auto Default
Instant jump.
Default
⚙02
smooth
Animated scroll.
Pattern
◉03
html
Whole page.
Scope
▦04
overflow
Inner panels.
Container
🔄05
reduced motion
Accessibility.
a11y
❓ Frequently Asked Questions
The scroll-behavior property controls whether scrolling happens instantly (auto) or with a smooth animated transition (smooth) when navigating via anchor links or programmatic scroll APIs.
Apply it to the html element for page-level smooth scrolling, or to any scrollable container with overflow: auto or overflow: scroll to smooth scrolling inside that box.
The default value is auto, which scrolls instantly without animation.
Yes. APIs like element.scrollIntoView({ behavior: 'smooth' }) and window.scrollTo({ top, behavior: 'smooth' }) work alongside CSS scroll-behavior on the scrolling container.
Yes. Many users prefer instant scrolling. Reset scroll-behavior to auto inside a prefers-reduced-motion: reduce media query.