This is a type of channel where you come thinking you know it all and by the time the video ends, you're 100 times wiser than before. Thank you very much Kevin!
It's probably worth including the thead and tbody. A sticky thead is great for big tables and/or small screens.
ปีที่แล้ว +7
I thought the same with the sticky thead. I think that github does it when viewen large files and it's very usefull. Also tbody tag I always asumed that browser puts it if you forget it, but maybe was just my imagination.
Arghhh... Those sticky headers are a bitch to implement. Especially, if you're table is horizontally scrollable. Would love to see a couple of decent solutions for this
instead of using the data-cell attribute, I would advocate for the use of headers attribute, which accepts a space separated values of the ids of the s that describes the cell. not only it can be used in the attr() function but with a small css/javascript you could add some cool functionalities to highlights specific cells of the same headers. on complex tables, it is common to have row and column headers, even group headers for a particular set of rows and columns, for those scenarios, and are also a good addition to the table markup
Not only that but it also makes it more accessible. Data attributes and "content" properties are not accessible as they are not part of the markup. While some assistive technologies may announce content in before/after psuedo elements it's best not to rely on this because it depends on the tool and user's settings. Given that before and after are mostly used for decorative purposes, these are often disabled by default, if at all.
@@wayneswildworld As in screen readers does not read data-attributes and often not decorative content on pseudo elements. They are not visible in the accessibility tree.
A video about responsive . Kevin, you are a hero. You could have mentioned the scope attribute also, but it is explained well in Adrian's blog posts. Thank you.
Oh THANK YOU KEVIN! I've struggled a bit with this because at some point you do just need to break the table into stacks or grids or something and the way tables work is just WEIRD. The question was what to do with it once you decide you've gotta break from table to something else, and what precisely that something else should be. Grid is obviously the solution, and while you used it to simply stack everything, you could come up with more complex layouts at a couple different screen sizes to account for e.g. desktop, tablet, and phone. I had an idea what doing this right might look like, I just needed to see the pieces assembled, so thank you for doing that!
Another approach that is more mobile-first is to start with a and style it with table attributes on larger screen sizes. Unfortunately, you still need a bit of extra markup to do the table heading.
Your video couldn't have arrived at a better time: I'm just finishing an API whose data needs to be displayed in a table. Your video helped me a lot. Thank you so much!
Your solution is great. I usually use the overflow one because most of the time data presented in tables is viewed on larger devices but now that I know that it's as easy and straight forward as this, I don't have to rely on a UI framework to handle tables. Thank you.
I have been looking for a simple approach like this. I was struggling a little with creating a responsive solution for data that was best put in a table, while keeping it accessible. I really like these solutions.
A great intro to responsive tables and a lot simpler than I imagined. As for adding data-cell="column heading", I generate most of my tables either through PHP or Javascript so that's pretty easy to add to the template, in this case a JS template string: `${data[field]}` The site is multi-lingual, hence the curLang[field] item.
I’m building a sports website (including F1) for my portfolio right now and I’m having a little trouble with the tables so this video is quite relevant to my interests 👍🏽
Make it responsive given the requirement, if you are building a B2B web app, where tables have large number of columns, and scroll horizontally even on computer screens, this might not be a solution you are looking for. Ask first, is my data a tabular data, or is it just for presentation, if it is just for presentation, then I don't think it should be a table in the first place. But I should add, that is a case study for corporations, most people won't have that, and this video is precisely what you need
Love the shout out to Adrian Roselli, he does amazing work on accessibility! On that note, I'm afraid the scrolling solution needs a little more to work properly, as Adrian also points out in "Under-engineered responsive tables". 1. It needs to be focusable otherwise you can't scroll by keyboard. Firefox does this automatically but other browsers do not. 2. It needs an accessible name so screen readers can tell the user what it is that has taken focus. 3. It needs a role so that the accessible name will be accepted.
I've been struggling with CSS and every video you made has clarified every issue i have with. Now i can make decent web sites that doesn't look as they were made for Netscape
Nice and simple explanation! Looks like a jump cut edited out the formatting of the before container width at the 20:56 mark. Things went from in-line to column formatting.
You can set up the table and all the data attributes with this emmet snippet: table>caption{The last 14 world F1 champions}+tr>th*6^tr*14>td[data-cell=name]+td[data-cell=poles]+td[data-cell=podiums]+td[data-cell=wins]+td[data-cell="career points"]+td[data-cell=championships]
Tables are the bane of modern CSS - This allows us to still use tables (for tabular data - maybe from anohter source), and still be responsive Great video!
Narrower viewports usually (though not always) are on mobile, which has a touch interface, and so the scrollbar at the bottom is less of an issue. Also, the thead and tbody would be good to add (browsers will probably add it in anyways, but it's better to specify it yourself so you can better troubleshoot things). For example the table headers (first row) got lumped into the tbody
FYI, in HTML5 browser adds TBODY automatically. Neither THEAD nor TFOOT is added automatically. In HTML4 and older nothing is added (so TR is direct child of TABLE).
Didn't know the semantic could break with CSS. I mean, of course I knew that a display : none would eventually prevent screen readers to describe an element, but I was not aware that a display block on a table,tr,td,... element would change its semantic. Thanks a lot !
When a content creator is out of touch about what type of audience he has, go back and fix that table. First, you messed up the table, then you didn't fix it, third you told us not to worry about it, but worst of all, you told us about it, NOW, that is all I'm looking at. We need you to post a video of the table fixed, thank you.
I know this "trick" from the default OutSystems Styles. Tables behave there like this too. I'm not thaaaat happy with the table result, but i think that's all you can expect from an easy and fast responsive approach. Great that you made it public!
The complete and proper nesting would be table caption colgroup thead (max 1) tfoot (max 1) tbody (1-n times) Yes *tfoot* comes before any tbody groups. The browser will still render it at the bottom. This is to support paged media rendering where the footer is repeated on every page
@@Silverflame1 it WILL work in all browsers 'cos that's how it was defined for ages and this falls into the "don't break the internet" category of backwards compatibility. Browsers have also always accepted a different ordering. I outlines the reason why it should come before tbody esp. for very long tables. Browsers will eventually reorder elements and also insert empty ones missing to complete the DOM.
Love or hate them, tables have their place in web design. I started designing sites with tables and this was before css files existed, all styles were tagged with each element. Fun times. Back then one didn't have to worry about responsiveness so it was easy to churn websites out at a high rate.
I remember doing this for a client 10 years ago, data attributes where not a thing, but :before and after were starting to be used, it was not as clean as this but content did the work.
Kevin, thank you for what you do! You taught us a lot for past few years! I felt in love with css and built my thinking process on how to build responsive layouts! Thank you very much! However, community demands part 2.
To me you are a CSS magician, all those commands you do out of your head. I make a lot of use of Bootstrap, but that reacts sometimes so weird. More and more i think i have to go back to basic CSS. Very good info on making a table responsive, thank you for sharing.
Someone else mentioned that data attributes are great for dealing with multiple languages, which I 100% agree with, Another good reason for that approach, vs the css version is if you have merged cells. The css version will mess things up vs the data-attribute version which won't.
I hope somewhen we'll be able to use accessability attributes in css. table { role: table; display: grid; } Very simple, clear and doesn't need any scripts.
Interesting usecase for data attributes. I do question why use a script to add roles rather than add them in the HTML though? In most situations, we aren't going to write tables by hand - we have some framework running a loop over some data to generate this output. Whether it's PHP, React, Vue, we will probably only write one row and repeat it with a loop. So it's not a lot of extra work to add the role attributes too. Of course, it's pretty unfortunate that CSS would change the semantics - that seems like the wrong approach for the standard to have taken. If it's a table, it's a table. The styles shouldn't take that away, and we shouldn't be forced to add more bloat to our markup to put it back.
Pretty neat skill to have. You will have to work with tables at some point in your FE job if you're working for companies. Also worth to learn about how to make the sticky thead or footer when scrolling. Just another tutorial idea 😁
Kevin what if we used grids for table layout? I think we could have much better control of everything. Position sticky will work + resize columns option.
Before my recent retirement, my team supported a LOT of HR-data related intranet sites where the output was tabular. We used the data-attribute method and it worked quite well. One thing with the display-grid method (which we did not use) is that it handles even narrower layouts since a single header/data element combo take up a single column, which would reduce the overflow seen around 23:55.
You forgot the GOAT - Latifi. I actually had a tough time tackling a responsive table about a month ago. And, sometime you just gotta use a table. I just implemented this solution. Thank you for doing this video. Also, I think Fernando changed his name to Alonstroll.
Nice one..... Not all web sites are "commercial sales" sites.. (cards etc)... some sites we create internally are for management to review preformance etc , and tables are a big part of those... tho' bootstrap does have useful utilis for these
Oh no, I didn't even notice when editing it! Browser fixed it for me since it will close unclosed tags for most things when it renders the page... Or at least I'm guessing it did and that's why I didn't notice
Great content as always. I remember that in this full stack MERN project I developed, I had to implement responsive tables as a functional reusable React component. I had like 4 or 5 tables in that website. I remember I used a base code from Codepen but I had to change several things in it as well and add others. It drove me nuts but I got it done. It was worth it. 👍
The accessibility fix should probably be done at compile/transpile time rather then at runtime. To make sure that the role (and other accessibility features) is added before JS is loaded.
@@najmantube Nataniel is suggesting to NOT use js to add the role. All the JS is doing is adding aria attributes, you can do this by hand when writing the HTML if you need to, or by adding it in with PHP or NodeJS on the server, etc.
6:40 Just a comment but back in the old days, if I were to do something like this, I would probably put it all into Excel and then convert the .xls to .htm so that I could view it beforehand and fix any mistakes in Excel before pasting them into my page. I tried this with today's Excel and it is a bit messy compared to 20 years ago but it is still possible to use Excel to create it then copy that to your page and clean it up if you want. BTW, after 20 years of not programming, I'm getting the itch to get back into it. Having fun with it for now. lol edit: I just tried this method out and it seems to still work pretty well as long as Excel skills are good. If they don't know Excel, I'd just write it out long hand instead. You don't get a nice clean result as we did 20 years ago, but an experienced person may find it helpful to use Excel for a table like this. As an aside: A simple Excel script can be written to make it even easier to turn an Excel table into a simple/basic HTML table.
Hmm... When I started doing web design, I was *excited* about tables, because they were new and not yet widely supported. It was such a pain trying to deal with the compatibility disparity. Once bitten, we weren't going to be forced to guess about compatibility on the next major feature!! Remember ? What a solution.
If somebody else is wondering, how the layout magincally changed @21:00, I think it was just recorded out of order and is using grid at this point that will be introduced later.
hi kevin! just a comment: be careful when you hide the row header completely, remember that tables are a matrix of crossed data (columns / rows), so each row cell needs the column reference, so by hiding it, that cell loses the reference, hence the SR is not gonna announce it, even if you add the data-cell attribute the user is gonna hear it, but they are actually inside a table, so they are gonna navigate it as such, expecting the columns to be there and heard as they navigate each row cell from left to right or viceversa the best way for this to work is to override all CSS from the thead (so it's not using any spacing/colors) and use a span to wrap its content with the famous "sr-only"/"visually-hidden" class only for smaller resolutions, that way the column headers are still semantically present but not visible; then inside each cell, use another span with the column's name (also only for small resolutions) and aria-hidden="true" attr to avoid SRs. Now the SR user is going to navigate through a table and visually it's going to look like a "list" more complex, yes, but this way you are covering all type of users and assistive technologies in a more semantic way
what i like to do on small sizes is to split (visually) the table rows, so they transform from table rows to self contained blocks/entities from a UI perspective
4:49 use templates with json data to make the table. That solves some of the issues for your copy/pasted JS. Also easier to convert when you have 100 or 50k records from an API. First "easy" version of the CSS is going to be better when you have 50k records with 20 plus rows. At some point you are magic numbering the max/min-width numbers, which is not really the best thing to do when you have data that might change.
Why wouldn't you use and when creating a table? I noticed you used the for the header but not nestled in a ? Also, would it be possible to make the mobile view an accordion? So you could touch the driver name and have it drop down the stats (closing the previously opened) or would that be asking too much of css?
You taught me CSS and now I'm one of the best in the whole University..
Thank you Kevin
This is a type of channel where you come thinking you know it all and by the time the video ends, you're 100 times wiser than before. Thank you very much Kevin!
It's probably worth including the thead and tbody. A sticky thead is great for big tables and/or small screens.
I thought the same with the sticky thead. I think that github does it when viewen large files and it's very usefull. Also tbody tag I always asumed that browser puts it if you forget it, but maybe was just my imagination.
Arghhh... Those sticky headers are a bitch to implement. Especially, if you're table is horizontally scrollable. Would love to see a couple of decent solutions for this
table tr:first-of-type {
position: sticky;
top: 0;
}
@@404-UsernameNotFound This doesn't work as-is
Regardless of the need for a sticky header, thead and tbody are surely the correct way to define a table semantically?
instead of using the data-cell attribute, I would advocate for the use of headers attribute, which accepts a space separated values of the ids of the s that describes the cell. not only it can be used in the attr() function but with a small css/javascript you could add some cool functionalities to highlights specific cells of the same headers. on complex tables, it is common to have row and column headers, even group headers for a particular set of rows and columns, for those scenarios, and are also a good addition to the table markup
Not only that but it also makes it more accessible. Data attributes and "content" properties are not accessible as they are not part of the markup. While some assistive technologies may announce content in before/after psuedo elements it's best not to rely on this because it depends on the tool and user's settings. Given that before and after are mostly used for decorative purposes, these are often disabled by default, if at all.
@@deallocWhat do you mean by not accessible?
@@wayneswildworld As in screen readers does not read data-attributes and often not decorative content on pseudo elements. They are not visible in the accessibility tree.
@@dealloc aaaah I understand! thanks for taking the time to respond!
@@wayneswildworld cant use the clipboard either
This is exactly what I was looking for for the last 2 years! THANK YOU!
You really should use and elements within the table around the respective sections.
A video about responsive . Kevin, you are a hero. You could have mentioned the scope attribute also, but it is explained well in Adrian's blog posts. Thank you.
Rico and Vettle real GOATs.
What a fabulous tutorial on tables. I’m really grateful for this. Thanks for working your CSS magic Kevin.
Oh THANK YOU KEVIN! I've struggled a bit with this because at some point you do just need to break the table into stacks or grids or something and the way tables work is just WEIRD. The question was what to do with it once you decide you've gotta break from table to something else, and what precisely that something else should be. Grid is obviously the solution, and while you used it to simply stack everything, you could come up with more complex layouts at a couple different screen sizes to account for e.g. desktop, tablet, and phone.
I had an idea what doing this right might look like, I just needed to see the pieces assembled, so thank you for doing that!
Another approach that is more mobile-first is to start with a and style it with table attributes on larger screen sizes. Unfortunately, you still need a bit of extra markup to do the table heading.
Kevin providing the knowledge once again! You're a life saver sometimes with the videos you create. They always seem to come at just the right time!
You are single handedly getting my through my Diploma. Thank god you exist my friend!
Your video couldn't have arrived at a better time: I'm just finishing an API whose data needs to be displayed in a table. Your video helped me a lot. Thank you so much!
just implemented this into our ticket-tracking system and people love it!
Rico "Bobby" Rosberg was undeniable, quite "suave". Definitely my favorite champion!
Your solution is great. I usually use the overflow one because most of the time data presented in tables is viewed on larger devices but now that I know that it's as easy and straight forward as this, I don't have to rely on a UI framework to handle tables. Thank you.
I have been looking for a simple approach like this. I was struggling a little with creating a responsive solution for data that was best put in a table, while keeping it accessible. I really like these solutions.
WOW. This is a gold mine. Thanks a lot Kevin. Am sure you will receive a lot of love because this has been a wish for many people.
Your all videos are worth to add in my youtube library for future references
A great intro to responsive tables and a lot simpler than I imagined.
As for adding data-cell="column heading", I generate most of my tables either through PHP or Javascript so that's pretty easy to add to the template, in this case a JS template string:
`${data[field]}`
The site is multi-lingual, hence the curLang[field] item.
Thank you, Kevin! You're like Joda CSS master. Be healthy and successful!
I’m building a sports website (including F1) for my portfolio right now and I’m having a little trouble with the tables so this video is quite relevant to my interests 👍🏽
Make it responsive given the requirement, if you are building a B2B web app, where tables have large number of columns, and scroll horizontally even on computer screens, this might not be a solution you are looking for.
Ask first, is my data a tabular data, or is it just for presentation, if it is just for presentation, then I don't think it should be a table in the first place.
But I should add, that is a case study for corporations, most people won't have that, and this video is precisely what you need
What a brilliant tutorial. Hits the mark perfectly and easy to follow. Thank you.
As someone who still does newsletters the old fashion way (coding them myself, using tables), I love the fact you’ve adresses this subject !
I love the way that your brain works.
Love the shout out to Adrian Roselli, he does amazing work on accessibility!
On that note, I'm afraid the scrolling solution needs a little more to work properly, as Adrian also points out in "Under-engineered responsive tables". 1. It needs to be focusable otherwise you can't scroll by keyboard. Firefox does this automatically but other browsers do not. 2. It needs an accessible name so screen readers can tell the user what it is that has taken focus. 3. It needs a role so that the accessible name will be accepted.
Finally. This IS not a video, THIS IS THE VIDEO!
I've been struggling with CSS and every video you made has clarified every issue i have with. Now i can make decent web sites that doesn't look as they were made for Netscape
Nice and simple explanation! Looks like a jump cut edited out the formatting of the before container width at the 20:56 mark. Things went from in-line to column formatting.
I like it that you choose F1. It made the video a lot more interesting 😊
I know this is an HTML table tutorial, but I certainly love the F1 aspect, and historically "Our Nige" is my favorite driver too!
Finally someone said use right element for the right purpose
As a brazilian, thank you for adding Senna!
Thanks so much, now I can complete my responsive table project.
You can set up the table and all the data attributes with this emmet snippet:
table>caption{The last 14 world F1 champions}+tr>th*6^tr*14>td[data-cell=name]+td[data-cell=poles]+td[data-cell=podiums]+td[data-cell=wins]+td[data-cell="career points"]+td[data-cell=championships]
Tables are the bane of modern CSS - This allows us to still use tables (for tabular data - maybe from anohter source), and still be responsive
Great video!
Narrower viewports usually (though not always) are on mobile, which has a touch interface, and so the scrollbar at the bottom is less of an issue. Also, the thead and tbody would be good to add (browsers will probably add it in anyways, but it's better to specify it yourself so you can better troubleshoot things). For example the table headers (first row) got lumped into the tbody
Also with mouse and keyboard Shift+mouse scroll scrolls horizontally
Exactly
FYI, in HTML5 browser adds TBODY automatically. Neither THEAD nor TFOOT is added automatically. In HTML4 and older nothing is added (so TR is direct child of TABLE).
I have known the era of « layout with table » too. CSS was not the same during the Jurassic !
I once had to design some email templates and I was grateful for modern CSS
@@precisionchoker That's why I avoid doing email templates
I feel you. Still a pain nowadays with email templates.
I was there Gandalf, 2000 years ago
@@precisionchoker😊
Holy timely, Batman! I just started looking into this yesterday.
Terrific ideas beyond the container overflow-x trick, which is what I have usually gone to. Thanks!
Didn't know the semantic could break with CSS. I mean, of course I knew that a display : none would eventually prevent screen readers to describe an element, but I was not aware that a display block on a table,tr,td,... element would change its semantic. Thanks a lot !
We're not using thead? I was wondering if that was part of accessibility or just declarative if your header has multiple rows?
When a content creator is out of touch about what type of audience he has, go back and fix that table. First, you messed up the table, then you didn't fix it, third you told us not to worry about it, but worst of all, you told us about it, NOW, that is all I'm looking at. We need you to post a video of the table fixed, thank you.
Oh thank God, you fixed it at 18:15
This video is exactly what I was looking for. Thank you!!
I never knew about using attributes in css, that's really cool
Oh man!! Responsive tables can't b more simple 😎, awesome 👍
Ah yes, my favourite F1 driver Rico Rosberg.
PS. Another awesome video Kev, keep rocking ❤️
I know this "trick" from the default OutSystems Styles. Tables behave there like this too.
I'm not thaaaat happy with the table result, but i think that's all you can expect from an easy and fast responsive approach.
Great that you made it public!
I had the trouble of working with tables and found a nice solution. Switching were possible from rows to columns, and placing the thread rows at first
The complete and proper nesting would be
table
caption
colgroup
thead (max 1)
tfoot (max 1)
tbody (1-n times)
Yes *tfoot* comes before any tbody groups. The browser will still render it at the bottom. This is to support paged media rendering where the footer is repeated on every page
Both developer mozilla and w3school mention that tfoot needs to come after tbody. It might still work for some browsers but it is not recommended.
@@Silverflame1 it WILL work in all browsers 'cos that's how it was defined for ages and this falls into the "don't break the internet" category of backwards compatibility.
Browsers have also always accepted a different ordering.
I outlines the reason why it should come before tbody esp. for very long tables. Browsers will eventually reorder elements and also insert empty ones missing to complete the DOM.
I've always had problems with tables, but this helps Kevin thanks
Love or hate them, tables have their place in web design. I started designing sites with tables and this was before css files existed, all styles were tagged with each element. Fun times. Back then one didn't have to worry about responsiveness so it was easy to churn websites out at a high rate.
I remember doing this for a client 10 years ago, data attributes where not a thing, but :before and after were starting to be used, it was not as clean as this but content did the work.
thanks so much for making this video - great solution for a responsive table.
Kevin, this is Awesome. I'm so glad I found your channel! Loving pretty much every video you put out!
This is absolutely amazing! Been needing this and am so glad you decided to cover it -- thank you so much!!
Fantastic fix for responsive table...the bain of my life!
Kevin, thank you for what you do! You taught us a lot for past few years! I felt in love with css and built my thinking process on how to build responsive layouts! Thank you very much!
However, community demands part 2.
This video has levelled up my approach to tables responsiveness. Thank you so much, Kevin!
This really helped me beef up my final, thank you!!
To me you are a CSS magician, all those commands you do out of your head. I make a lot of use of Bootstrap, but that reacts sometimes so weird. More and more i think i have to go back to basic CSS. Very good info on making a table responsive, thank you for sharing.
Someone else mentioned that data attributes are great for dealing with multiple languages, which I 100% agree with, Another good reason for that approach, vs the css version is if you have merged cells. The css version will mess things up vs the data-attribute version which won't.
Awesome video, very helpful. The data-cell attribute approach works for me because I create tables dynamically in code.
It's Amazing! So simple and so workable. Thank you!
Thank you, Kevin! This is a great solution!
This is even awesome for people that sometimes still have to use tables for, for example emails.
I hope somewhen we'll be able to use accessability attributes in css.
table { role: table; display: grid; }
Very simple, clear and doesn't need any scripts.
Thank you so much Kevin! This is exactly what I needed, I left a comment on some previous video asking for this topic. Much appreciated!
Interesting usecase for data attributes. I do question why use a script to add roles rather than add them in the HTML though? In most situations, we aren't going to write tables by hand - we have some framework running a loop over some data to generate this output. Whether it's PHP, React, Vue, we will probably only write one row and repeat it with a loop. So it's not a lot of extra work to add the role attributes too. Of course, it's pretty unfortunate that CSS would change the semantics - that seems like the wrong approach for the standard to have taken. If it's a table, it's a table. The styles shouldn't take that away, and we shouldn't be forced to add more bloat to our markup to put it back.
Absolutely god tier video
Thank you alot, so simple but very effective solution.
Pretty neat skill to have. You will have to work with tables at some point in your FE job if you're working for companies. Also worth to learn about how to make the sticky thead or footer when scrolling. Just another tutorial idea 😁
Kevin what if we used grids for table layout? I think we could have much better control of everything. Position sticky will work + resize columns option.
your videos are awsome!!!
learning a ton with them! Thank you kind sir
Before my recent retirement, my team supported a LOT of HR-data related intranet sites where the output was tabular. We used the data-attribute method and it worked quite well.
One thing with the display-grid method (which we did not use) is that it handles even narrower layouts since a single header/data element combo take up a single column, which would reduce the overflow seen around 23:55.
You forgot the GOAT - Latifi.
I actually had a tough time tackling a responsive table about a month ago. And, sometime you just gotta use a table.
I just implemented this solution. Thank you for doing this video.
Also, I think Fernando changed his name to Alonstroll.
your highness sir!❤
Nice one..... Not all web sites are "commercial sales" sites.. (cards etc)... some sites we create internally are for management to review preformance etc , and tables are a big part of those... tho' bootstrap does have useful utilis for these
Thank you for this valuable video! Kevin, it is the best solution for my project!
Geat till now, but as quick note, @ 15:21 you delete , but 15:27 you delete the ending tag for table insteal of the ending tag for div.
Oh no, I didn't even notice when editing it!
Browser fixed it for me since it will close unclosed tags for most things when it renders the page... Or at least I'm guessing it did and that's why I didn't notice
Great content as always. I remember that in this full stack MERN project I developed, I had to implement responsive tables as a functional reusable React component. I had like 4 or 5 tables in that website. I remember I used a base code from Codepen but I had to change several things in it as well and add others. It drove me nuts but I got it done. It was worth it. 👍
The accessibility fix should probably be done at compile/transpile time rather then at runtime. To make sure that the role (and other accessibility features) is added before JS is loaded.
How can the role etc get added before the JS is loaded if we're using JS to add the role etc?
@@najmantube Nataniel is suggesting to NOT use js to add the role. All the JS is doing is adding aria attributes, you can do this by hand when writing the HTML if you need to, or by adding it in with PHP or NodeJS on the server, etc.
@@TheNeonRaven Yes thanks, got it (see my previous comment).
Thanks Kevin for your generous knowledge sharing. How to suggest topic(s) for your future videos?
Love this so much Kevin... Always had to run to grid when to deal with it.. Thank you so much
6:40 Just a comment but back in the old days, if I were to do something like this, I would probably put it all into Excel and then convert the .xls to .htm so that I could view it beforehand and fix any mistakes in Excel before pasting them into my page. I tried this with today's Excel and it is a bit messy compared to 20 years ago but it is still possible to use Excel to create it then copy that to your page and clean it up if you want.
BTW, after 20 years of not programming, I'm getting the itch to get back into it. Having fun with it for now. lol
edit: I just tried this method out and it seems to still work pretty well as long as Excel skills are good. If they don't know Excel, I'd just write it out long hand instead. You don't get a nice clean result as we did 20 years ago, but an experienced person may find it helpful to use Excel for a table like this.
As an aside: A simple Excel script can be written to make it even easier to turn an Excel table into a simple/basic HTML table.
Hmm... When I started doing web design, I was *excited* about tables, because they were new and not yet widely supported. It was such a pain trying to deal with the compatibility disparity. Once bitten, we weren't going to be forced to guess about compatibility on the next major feature!! Remember ? What a solution.
Omg, I’d almost managed to forget the days of table layout and single pixel transparent gifs everywhere
This is awesome and very helpful. Thanks Kevin keep up the great work.
If somebody else is wondering, how the layout magincally changed @21:00, I think it was just recorded out of order and is using grid at this point that will be introduced later.
This is great, cause I am just about to create table in NextJs app that I am actually working on in my youtube channel so thanks a lot Kevin 👍
I also like to use the thead, tbody and tfoot. Gives a bit more flexibility for styling.
hi kevin! just a comment: be careful when you hide the row header completely, remember that tables are a matrix of crossed data (columns / rows), so each row cell needs the column reference, so by hiding it, that cell loses the reference, hence the SR is not gonna announce it, even if you add the data-cell attribute the user is gonna hear it, but they are actually inside a table, so they are gonna navigate it as such, expecting the columns to be there and heard as they navigate each row cell from left to right or viceversa
the best way for this to work is to override all CSS from the thead (so it's not using any spacing/colors) and use a span to wrap its content with the famous "sr-only"/"visually-hidden" class only for smaller resolutions, that way the column headers are still semantically present but not visible; then inside each cell, use another span with the column's name (also only for small resolutions) and aria-hidden="true" attr to avoid SRs. Now the SR user is going to navigate through a table and visually it's going to look like a "list"
more complex, yes, but this way you are covering all type of users and assistive technologies in a more semantic way
You should make video about it.
In email marketing, I use tables on a daily basis, thanks for the video!
what i like to do on small sizes is to split (visually) the table rows, so they transform from table rows to self contained blocks/entities from a UI perspective
4:49 use templates with json data to make the table. That solves some of the issues for your copy/pasted JS. Also easier to convert when you have 100 or 50k records from an API.
First "easy" version of the CSS is going to be better when you have 50k records with 20 plus rows. At some point you are magic numbering the max/min-width numbers, which is not really the best thing to do when you have data that might change.
I've been using the tailwind table utility classes and tanstack-table for implementing tables and data-grids 😅... Also a big F1 fan!!!
Really inspired by this video. Thanks.
Why wouldn't you use and when creating a table? I noticed you used the for the header but not nestled in a ?
Also, would it be possible to make the mobile view an accordion? So you could touch the driver name and have it drop down the stats (closing the previously opened) or would that be asking too much of css?