Smooth Scrolling for Anchor Links
Makes in-page anchor links scroll smoothly instead of jumping, while respecting visitors who prefer reduced motion.
Opens WPIDE on
Code
html {
scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
html {
scroll-behavior: auto;
}
}
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.