HTML Tables


You will come across information that is best when put into tables. HTML allows you to input tables through the Tables Tag. This tag has an opening tag and a closing tag. The table tag is very simple in its usage.

 

You can insert a table in your HTML page, by specifying:

 

<table>

</table>

 

Now, a table has a certain number of rows and columns, so you need to include tags on this as well in your HTML page. These specifications will obviously come after the table tag.

 

Table rows will be specified using <tr> tag and the table columns will be specified using the <td> tag.

 

 

 

Example

 

Here is how you specify a table with all relevant tags put together:

 

<table>

<tr>

<td>

</td>

</tr>

</table>

 

This is a single table with one row one column. It looks like this

 

 

 

Example

 

 If you to add another row, this is how you need to add code.

 

<table>

<tr>

<td

</td>

</tr>

<tr>

<td>

</td>

</tr>

</table>

 

This is a table with two rows and one column.

 

 

 

 

Example

 

Here is how you specify two columns in a single row. You can add data to the columns also:

 

<table>

<tr>

<td>column 1</td>

<td>column 2</td>

</table>

 

Column 1

Column 2

 

Column 1 and Column 2 has been input as the text to be displayed in the respective columns on output.

 

The number of rows and columns you want, should be specifically  in the table tag placed in your HTML body.

 

Example

 

Here is a look at a table with three rows and two columns and some data in the columns:

 

<table>

<tr>

<td>First row first column</td>

<td>First row second column </td>

</tr>

<tr>

<td>Second row first column</td>

<td>Second row second column</td>

</tr>

<tr>

<td>Third row first column</td>

<td>Third row second column</td>

</tr>

</table>

 

 

First row first column

First row first column

Second row first column

Second row first column

Third row first column

Third row first column

 

You can set the border width for your table. This is done by the border attribute.

 

Example

 

<table border="1">

</table>