Table with Sticky First Column Template

Keep row context in view on wide tables with this sticky first column effect.

Using position: sticky, this template freezes the first column, allowing users to scroll horizontally through many columns of data without ever losing track of which row they are on.

Screenshot of a wide table being scrolled horizontally, with the first column remaining frozen in place.

Get Source Code → Preview →

About this Sticky Column Table

This template is the perfect companion to a horizontally scrollable table. When dealing with wide datasets, it's easy for a user to scroll right and forget which item the data belongs to. By making the first column "sticky", you ensure the primary identifier for that row (like a name, ID, or product) is always visible.

This is achieved using the same modern CSS property as the sticky header: position: sticky. By applying this property along with left: 0; to the first th and td in each row, they will "stick" to the left edge of the scrolling container. A solid background color on these sticky cells is crucial to hide the other columns as they scroll underneath.

Features

Important Implementation Notes

Dependencies

None. Relies on modern browser support for position: sticky.

Code

Here's the full code for the sticky first column table:

View Output