create a table using HTML
Create a table using HTML
To create a table using HTML, you can use the <table>
element and its related tags to define the structure of the table. Here's an example of a basic table with two rows and two columns:
<table> <tr> <th>Column 1</th> <th>Column 2</th> </tr> <tr> <td>Row 1, Cell 1</td> <td>Row 1, Cell 2</td> </tr> <tr> <td>Row 2, Cell 1</td> <td>Row 2, Cell 2</td> </tr> </table>
Let's break down the code above:
- The
<table>
element is used to define the table. - The
<tr>
element is used to define each row of the table. - The
<th>
element is used to define a header cell. Header cells are typically used to label the columns of the table. - The
<td>
element is used to define a data cell. Data cells contain the actual data in the table.
In the example above, the first row of the table contains two header cells (<th>Column 1</th>
and <th>Column 2</th>
), and the remaining rows contain two data cells each (<td>Row 1, Cell 1</td>
and <td>Row 1, Cell 2</td>
, etc.).
Comments
Post a Comment