Use Tbody -Thead

Hello. Why use tbody and thead in table?Why don’t
use all table element in same place?
Ex:

Hello @Ekrem.Bulut,
<tbody> and <thead> is part of HTML5 that is actually very useful for the readability of code. It is called semantic tags. It means that the tag means exactly what it says. So <thead> means its the head of the table. There are a lot of semantic tags out there. Here are some of them:

<header>Header</main>
<main>Main Content</main>
<footer>Footer</footer>
<section> Section</section>
<nav>Nav Bar</nav>
<!-- And Much More -->

It’s sole purpose is for readibility on the code with added functions. It is easier to read those above than doing these:

<div class="nav-bar">Nav</div>
<div class="footer"></div>

You can learn more about semantic tags here :

2 Likes

All right!

name age job
x 30 doctor
y 29 police
        </tr>
        

    </thead>

    <tbody>
        <tr>
            <th>x</th>
            <th>30</th>
            <th>doctor</th>
        </tr>
        <tr>
            <th>y</th>
            <th>29</th>
            <th>police</th>
        </tr>





    </tbody>
</table>

What is difference between them? Only readability? They seem same in website.

name age job

Well in a table, anything inside the <thead> will be put at the top of the table and is usually emphasized because it is the header. Inside of <thead> is also always <th> instead of <td> to turn it into header. Then <tbody> will be underneath the head.

So this will be
Hello thead
hello tbody
1 Like

https://drive.google.com/file/d/1tDP5nR7wuKVw1D2z3dvHZZzEK7MLVemQ/view?usp=sharing
If you click this, you can see :slight_smile: