Tables
Tables are the most useful tool you will have in HTML to control where items are placed on a page. At first glance, the HTML code of a table is intimidating. Once you have time to create a few tables, you will understand what each part of the code does. A table is a series of rows and columns. There are three main tags used in a table. |
| <table></table> | Designates the beginning and ending of the table |
| <tr></tr> | Designates the beginning and ending of a single row |
| <td></td> | Designates the beginning and ending of a column. |
The original HTML specification called for all tables to automatically have a border as the table above. Since then, that rule has gone away. To get the border to show up in a modern browser, the border tag must be used. The border tag is added to the table tag as follows: <table border="1"></table> where the number equals the thickness of the border. A border set to zero will not appear on the page. There are some simple rules about how table tags work.
Code for a 2x2 table will look like this (I have indented only to make it easier to read) |
| HTML Code | Browser Display | ||||
|
<table> |
|
It will take you a little time to adjust to placing the second column under the first column, but you will get used to it. You can place them side by side, as they are displayed in the browser, but you will find that the long row of HTML is harder to read in your editor. Just remember this--Nothing goes in between <table> and <td> except <tr>... No text... No Tags. All the data that you want displayed in the table must be between the table data tags <td>Data Goes Here</td>. Just like other tags, tables can be nested inside of each other. In fact, this is a very useful formatting technique. |
| Our School Schedule | |||||||||||||
| Academics Sports Band Administrative |
|
I have placed borders around all the above tables. This is only to make the tables easier to see. Most of the tables you will use for formatting will have the border set to zero. Below is the same table as above, with the borders removed, and some background colors added. |
| Our School Schedule | |||||||||||||
|
Academics Sports Band Administrative |
|
| You'll learn how to do this sort of magic later. I'm only putting it in here to show the formatting power of tables. |
| Jump To Top | Hyperlinks |
|