TUTORIALS » HTML / JavaScript » HTML essentials (guided tutorials)Tables in HTMLPage 1 of 6You are in page:» 1. The basics
Tables are essential in presenting information and even creating some web page layouts. There are three basic tags used for creating tables:
• <table>to declare the table contents • <tr>to declare a new row in the table • <td>to declare each cell inside a row These three tags must be nested in that exact order. <td>'s inside <tr>'s, and <tr>'s inside the main <table>tag. So, to create a table with 3 rows and 2 columns, we use the following code: <table border="1"> <tr> <td>Cell 1</td> <td>Cell 2</td> </tr> <tr> <td>Cell 3</td> <td>Cell 4</td> </tr> <tr> <td>Cell 5</td> <td>Cell 6</td> </tr> </table> This will create a table like:
Note that I am using the border attribute to specify a border width of 1 pixel, this way you can see the structure of the table in our example.
The logic in creating basic tables is pretty easy to catch once you have practiced with two or three examples, isn't it? Are you ready to do it on your own?
Table borderYou can set the border width to any number of pixels you want. If you set the border attribute to "0" or if you just don't write the border attribute at all, you will have no visible border in your table.
Test each one of the following border values on a table:
<table border="1"> <tr>... <table border="10"> <tr>... <table border="0"> <tr>... <table> <tr>... Are you ready? Follow through the next pages of this tutorial!
|
|