Logo

Create HTML Table with Semantic Elements

Create HTML Table with Semantic Elements

Create HTML Table with Semantic Elements

Once you have the basics of HTML tables down, it’s time to add more structure and meaning to your tables. Using semantic elements like <thead>, <tbody>, and <tfoot> helps organize your table content and improve accessibility.

Semantic Elements

Benefits of Using Semantic Elements

  • Improved Accessibility: Screen readers can better understand the table structure.
  • Better Organization: Makes your HTML code cleaner and easier to maintain.
  • Enhanced Styling: Allows for more precise CSS targeting.
				
					<!DOCTYPE html>
<html>
<head>
    <title>HTML Table with Thead, Tbody, and Tfoot</title>
</head>
<body>
    <h1>Structured HTML Table</h1>
    <table border="1">
        <thead>
            <tr>
                <th>Header 1</th>
                <th>Header 2</th>
                <th>Header 3</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>Data 1</td>
                <td>Data 2</td>
                <td>Data 3</td>
            </tr>
            <tr>
                <td>Data 4</td>
                <td>Data 5</td>
                <td>Data 6</td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <td>Footer 1</td>
                <td>Footer 2</td>
                <td>Footer 3</td>
            </tr>
        </tfoot>
    </table>
</body>
</html>

				
			

Conclusion :

Adding semantic elements to your HTML tables not only improves their structure but also makes them more accessible and easier to style. Start incorporating <thead>, <tbody>, and <tfoot> in your tables to create more organized and maintainable code.

Scroll to Top