Working with tables in HTML
Now we will learn how to make tables in HTML. I think you can imagine what a table is in everyday life - it is a set of rows and columns, at the intersection of which are cells.
In HTML, tables are created using a similar principle. There are also columns and rows with cells, but the HTML code for tables may seem unusual at first glance: tables are created by rows - first the first row, then the second, and so on.
The table code has a rigid structure: the main tag is table
, inside which there should be tr
tags that create table rows, and inside them - td
tags that create cells. The table
tag can have the border
attribute, which sets the border for the table and its cells.
Let's make a table with three rows and three cells in each row as an example:
<table border="1">
<!--This will be the first row of the table:-->
<tr>
<td>cell 1</td>
<td>cell 2</td>
<td>cell 3</td>
</tr>
<!--This will be the second row of the table:-->
<tr>
<td>cell 4</td>
<td>cell 5</td>
<td>cell 6</td>
</tr>
<!--This will be the third row of the table:-->
<tr>
<td>cell 7</td>
<td>cell 8</td>
<td>cell 9</td>
</tr>
</table>
:
Repeat the example below: