This is a relatively well-known pattern for responsive tables, but it's worthwhile to give a reminder or FYI to the new folks. I've also tried to make it accessible for screen readers.
I've used this method a lot, I generally think it's one of the better ways to display data that needs a certain format to be understood.
Thanks for this, works great and I'm about to implement it on something I'm working on.
I was wondering, is it an issue that the table header elements have the scope value of col, and when the layout changes their scope should then be row.
This is exactly what I've been looking for. Thanks!
Thank you very much for this pen, Mr. Smith!
I have implemented this and it works fine when I resize the window on desktop, but on mobile, the table still goes outside the borders of the screen?
Thanks! I just created a jQuery plugin which may become handy with tables from content editors.
Why aren't you using display: none; for the thead (in responsive mode`
@vsync display: none and visibility: none hide elements from screen readers. The code in the thead keeps the data accessible to screen readers while still hiding the element from regular users.
Very good result, but W3Schools says "The
Need to know how to enable it? Go here.