{"id":292192,"date":"2019-07-12T15:31:21","date_gmt":"2019-07-12T22:31:21","guid":{"rendered":"http:\/\/css-tricks.com\/?p=292192"},"modified":"2020-03-05T06:24:58","modified_gmt":"2020-03-05T13:24:58","slug":"position-sticky-and-table-headers","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/position-sticky-and-table-headers\/","title":{"rendered":"Position Sticky and Table Headers"},"content":{"rendered":"

You can’t position: sticky;<\/code> a <thead><\/code>. Nor a <tr><\/code>. But you can sticky a <th><\/code>, which means you can<\/em> make sticky headers inside a regular ol’ <table><\/code>. This is tricky stuff, because if you didn’t know this weird quirk, it would be hard to blame you. It makes way more sense to sticky a parent element like the table header rather than each individual element in a row. <\/p>\n

<\/p>\n

The issue boils down to the fact that stickiness requires position: relative<\/code> to work and that doesn’t apply to <thead><\/code> and <tr><\/code><\/a> in the CSS 2.1 spec. <\/p>\n

There are two very extreme reactions to this, should you need to implement sticky table headers and not be aware of the <th><\/code> workaround. <\/p>\n