To create tables in HTML, you can use the <table>
, <tr>
, <th>
, and <td>
tags. Here’s an example of how you can create a basic table:
<!DOCTYPE html> <html> <head> <title>Table Example</title> </head> <body> <table> <tr> <th>Header 1</th> <th>Header 2</th> <th>Header 3</th> </tr> <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> </table> </body> </html>
In this example, we have a table with three columns and two rows. The <table>
tag represents the entire table. Inside the table, we use the <tr>
tag to define table rows. Each row contains cells represented by the <td>
tags for regular data. For header cells, we use the <th>
tag instead of <td>
. By default, browsers render the contents of <th>
with bold text.
You can add more rows or columns by duplicating the <tr>
and <td>
elements as needed. You can also use CSS to style the table, apply borders, set background colors, and modify other visual aspects to match your desired design.