To make in-page links scroll smoothly, set scroll-behavior: smooth on the root element, html. For accessibility, turn that effect off when a visitor has requested reduced motion:
html {
scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
html {
scroll-behavior: auto;
}
}
Use ordinary anchor links with matching element IDs. For a separately scrollable panel, put the same rules on that panel instead of html.
Make anchor links scroll smoothly
A link such as <a href="#features">Features</a> navigates to the element whose ID is features. The browser normally moves directly to the destination. Setting scroll-behavior: smooth on the root element changes that navigation to a smooth scroll.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Smooth in-page navigation</title>
<style>
html {
scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
html {
scroll-behavior: auto;
}
}
</style>
</head>
<body>
<nav aria-label="On this page">
<a href="#features">Skip to features</a>
</nav>
<main>
<section style="min-height: 100vh">
<h1>Overview</h1>
<p>Scroll down, then use the link above to return to this section.</p>
</section>
<section id="features">
<h2>Features</h2>
<p>This is the destination of the in-page link.</p>
</section>
</main>
</body>
</html>
The link remains a real link: it works without JavaScript and retains normal browser navigation behavior. CSS changes how the browser moves to the target; it does not replace the link.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Choose the right scrolling element
Document viewport
For page-wide anchor navigation, put the declaration on html, the document root. The viewport is the scrolling box in this case. Setting scroll-behavior on body does not propagate the behavior to the viewport, so it may appear not to work as intended. See MDN’s scroll-behavior reference.
Nested scrollable region
If a panel has its own scrollbar, apply the rule to that scroll container. Its contents will then scroll smoothly when navigation or a scrolling API targets something inside it:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
.scroll-container {
height: 20rem;
overflow-y: auto;
scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
.scroll-container {
scroll-behavior: auto;
}
}
Use the actual element that scrolls. Applying the declaration to an outer wrapper that does not own the scrolling position will not control the inner panel.
Respect reduced-motion preferences
The prefers-reduced-motion: reduce media query matches when a visitor has enabled their device or operating-system setting to reduce non-essential motion. Overriding smooth scrolling with auto gives those users instant movement instead. Keep the override after the general rule so it wins in the cascade. MDN explains the preference and its accessibility context in its prefers-reduced-motion reference.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Do not add smooth scrolling globally without considering this preference. Motion that feels subtle to one visitor can cause discomfort for someone with a vestibular disorder.
What smooth scrolling does—and does not—control
The property applies when scrolling is triggered by navigation or by CSSOM scrolling APIs. It does not alter direct user scrolling with a mouse wheel or touch gesture. Its two main values are:
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
| Value | Behavior | Typical use |
|---|---|---|
auto |
Scrolls instantly. | Default-like behavior and reduced-motion overrides. |
smooth |
Scrolls smoothly using timing selected by the browser. | In-page links and programmatic navigation where motion is appropriate. |
CSS does not provide a duration or easing curve for scroll-behavior. The browser chooses both. The W3C CSSOM View Module specifies that smooth scrolling occurs over a user-agent-defined amount of time and in a user-agent-defined fashion; scrolling can also be aborted by an algorithm or by the user. The property is not animatable.
Check that the destination behaves as expected
- Confirm the link’s fragment exactly matches an element ID, for example
href="#pricing"andid="pricing". - Check that the CSS rule applies to the root element for document scrolling, or to the scrolling panel for nested scrolling.
- Test with reduced motion both enabled and disabled; the former should use the instant
autobehavior. - Test keyboard navigation as well as pointer activation. Native anchor links preserve the browser’s usual navigation semantics.
Troubleshooting
The page jumps instead of scrolling
Make sure scroll-behavior: smooth is applied to html, not only body, and check that no later rule overrides it with auto. Also check whether reduced motion is enabled; with the recommended media query, an instant jump is expected in that case.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
A panel’s links move the page, not the panel
Verify that the panel is actually scrollable—for example, it has constrained height and overflow-y: auto—and apply scroll-behavior to that same element. A declaration on the document root controls viewport scrolling, not every nested box.
Wheel or touch scrolling is unchanged
That is expected. This property affects scrolling initiated by navigation and CSSOM scrolling APIs, not direct user input.
The scroll speed or easing is not what I want
scroll-behavior has no CSS controls for duration or easing; browsers choose those details. If you need a specific animation, this property alone does not provide it. Avoid overriding a user’s reduced-motion preference when designing any custom motion.
Browser support
MDN marks scroll-behavior as Baseline Widely available and reports availability across browsers since March 2022. Browsers are permitted to ignore the property, so if a particular minimum browser version is a requirement, check MDN’s current compatibility table for the browsers you support.
Or skip the browser setup
If your goal is a screenshot rather than implementing page navigation, ScreenshotNeo is a website screenshot API and MCP server. Its one-call API can capture a page as PNG, JPEG, WebP, or PDF:
Quick Recap
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for parameters and setup. Before capture, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server gives AI agents tools to take screenshots, get page information, and capture PDFs. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.
Sign up for ScreenshotNeo’s free plan.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

