📌 CSS

position: sticky — The Most Useful CSS You're Not Using

📅 Jun 26, 2026 ⏱ 3 min read

Sticky elements scroll normally until they hit an edge, then pin. Navbars, sidebars, table headers — one property, no JavaScript.

Basic usage

.navbar {
  position: sticky;
  top: 0;            /* REQUIRED — the pin distance */
  z-index: 100;
}
.sidebar { position: sticky; top: 80px; }   /* below a sticky navbar */
th { position: sticky; top: 0; }            /* table headers! */

Why sticky "doesn't work" — the 4 causes

The sidebar on our course pages is position: sticky — inspect it and see.

← All Articles