To create table in HTML we use <table>, <tr>, <th>, and <td>.
But nowadays I see often <thead>, <tfoot>, and <tbody>` used. Is this a new method of HTML? Why is this needed too? What are the benefits of doing it like this?
To create table in HTML we use <table>, <tr>, <th>, and <td>.
But nowadays I see often <thead>, <tfoot>, and <tbody>` used. Is this a new method of HTML? Why is this needed too? What are the benefits of doing it like this?
Refer to HTML <thead> Tag. It gives the browser more information about the table, allowing it to make smarter choices when displaying the table.
For example: When scrolling in a big table, the header might be locked to the top of the screen, so you do not need to scroll up to find out what a column meant.
Theey are just new tags used to specify each part of a table (body, header, and footer). Before it was possible only with the <th>
tag (header).
It might be easier to style these elements with CSS too.
First you should know that HTML has already been upgraded to HTML5. So previously HTML tags didn't have the tags such as you mentioned so <thead> is for the table header, <tfoot> for the footer and <tbody> is the same as body when you are starting a HTML page.
For more information, better go to HTML5 Demos and Examples.
It is just an advanced way of writing HTML table tags (body, head, and footer).