---
title: "How to Create a Shrinking Header on Scroll Without JavaScript"
url: https://daily.dev/posts/how-to-create-a-shrinking-header-on-scroll-without-javascript-oevpab8fg
source_url: https://css-tricks.com/how-to-create-a-shrinking-header-on-scroll-without-javascript/
type: article
source: "CSS-Tricks"
published: 2021-02-16T22:00:16.496Z
updated: 2021-10-07T14:17:10.317Z
tags: ["javascript", "containers"]
reading_time: 2
upvotes: 43
comments: 3
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Create a Shrinking Header on Scroll Without JavaScript

**[CSS-Tricks](https://daily.dev/sources/css_tricks)** · 2 min read · 43 upvotes · 3 comments

## Summary

Sticky headers are a way to shrink a website’s header without using JavaScript. The inner container contains all the header elements, such as the logo and the navigation. The outer container is in a way the actual header, while the only function of the parent element is to make the header taller.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://css-tricks.com/how-to-create-a-shrinking-header-on-scroll-without-javascript/>

## Community discussion

Top comments from developers on daily.dev.

**@halcolo** · 3 upvotes

> Useful and interesting to know new ways to do different thinks without JS.

**@faisalali19** · 2 upvotes

> Awesome will try it in next project.

**@idoshamun** · 0 upvotes

> What an awesome trick!

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 0 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments
- [CNCF Unveils Schedule for KubeCon \+ CloudNativeCon Europe 2026](https://daily.dev/posts/cncf-unveils-schedule-for-kubecon-cloudnativecon-europe-2026-ikhcoa5cb) · CNCF · 2 upvotes · 0 comments
- [CNCF Debuts KubeCon \+ CloudNativeCon Japan 2026 Schedule](https://daily.dev/posts/cncf-debuts-kubecon-cloudnativecon-japan-2026-schedule-xp5pyudub) · CNCF · 1 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#containers](https://daily.dev/tags/containers)

[View this post on daily.dev](https://daily.dev/posts/how-to-create-a-shrinking-header-on-scroll-without-javascript-oevpab8fg)
