This is a real failure of browsers, by the way. The table HTML has all the semantic information necessary, browsers could use it to improve table usability (such as sticky headers) but none ever bothered to try.
th { position: sticky; top: 0; }
I don't think it would have been reasonable to include/force such functionality at the spec level.