How to automatically scroll to an element on a page

Different ways to automatically scroll to a particular HTML element on a page.

How to scroll to an element only if needed (using JavaScript)

Learn how to automatically scroll to an element on a page only if it’s outside the viewport or hidden behind a sticky header.

Smooth scrolling using only CSS

Learn how to create smooth auto-scroll using one simple CSS property.

How to fix auto-scroll position so the target element is not hidden behind a sticky header (using only CSS)

Learn how to easily fix the issue where the target element is covered behind a sticky header when auto-scrolling using JavaScript or anchor links.