Skip to main content
Login Join
Snippet · CSS

Sticky Header

Shared by Mukesh Gujjar · July 26, 2026

1 copy
1 view
Back to Snippets

2 approaches to this. Compare them and pick what fits your setup.

Main approach by Mukesh Gujjar

Keep the website header visible while scrolling. This improves navigation and user experience, especially on long pages.

Usage

Apply the .site-header class to your header element.

<header class="site-header">
<!-- Header Content -->
</header>

.site-header {
    position: sticky;
    top: 0;
    z-index: 999;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments