Make a table in HTML
Here's how to make a basic table with HTML:
<td>row 1 cell 1</td>
<td>row 1 cell 2</td>
<td>row 2 cell 1</td>
<td>row 2 cell 2</td>
It will look like this:
|row 1 cell 1||row 1 cell 2|
|row 2 cell 1||row 2 cell 2|
What's going on, here?
<table> </table> encloses the whole table.
<tr> </tr> defines a new row within the table.
<td> </td> defines a new column within a row.
Notice how columns are nested within rows, and all the rows are nested within a table.
How do I make borders in my table?
This is done within the first <table> tag using the border attribute.
It looks like this:
This produces a table with a 1 pixel wide border around it. If you type 2 in place of the 1, it will be a 2 pixel wide border, etc.
How do I define the width of a table?
This is done within the first <table> tag using the width attribute.
It would look like this:
This produces a table 500 pixels wide.
If you wanted a table to be 500 pixels wide with a 1pixel border, your opening <table> tag would look like this:
<table width="500" border="1">