Forum digitalis

1.8 Tables

Introduction

HTML provides specific elements for displaying tabular data. <table> defines the entire table, <tr> defines individual rows, <th> defines table headers, and <td> defines table cells. The <thead> element marks the table header, while <tbody> marks the main body of the table.

Example

The following example shows a simple table with a header and body section.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Tables</title> </head> <body> <table border="1"> <thead> <tr> <th>Name</th> <th>Age</th> <th>Occupation</th> </tr> </thead> <tbody> <tr> <td>Anna</td> <td>25</td> <td>Teacher</td> </tr> <tr> <td>Ben</td> <td>30</td> <td>Engineer</td> </tr> </tbody> </table> </body> </html>