This lesson looks at some of the formatting options available with tables
Tables have the same function in the web as they do in a printed document. They are made up of rows and columns. The intersection of a row and column is a cell
cell
Tables are started and ended with the html code <table></table>
Rows are started and ended with the code <tr></tr> (table row)
Cells (columns in a row) are started and ended with the code <td></td> (table data)
The table shown above would have the following html code. HTML codes are in red and comments are in green.
<table>
<tr>
<td>cell</td> <!---- this cell has contents , the word "cell">
<td></td> <!---- this cell no contents>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr></table>
You should know that when you make tables in FrontPage, it always puts the HTML blank character code, , in each cell. This makes sure that the browser draws all the cells on screen, even if they are apparently empty,
Tables have a number of parameters that can be set, including
When table width is given in percent, it resizes when you resize the browser. When table width is given in pixels (as this page does) it does not resize when you resize the browser window.
In use, these two settings look like this
<table border=1 width="400">
and used in the table shown above, looks like this
<table table border=1 width="400"> <!---- table settings>
<tr>
<td>cell</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr></table>
Table data (cells) also have settings, including these
In use, these settings look like this
<table border="0" cellpadding="4" cellspacing="5" width="525">
<!---- no border, cell padding 4 pixels, cell spacing 5 pixels, table width 525 pixels><tr>
<td width="33%"> </td> <!---- cell is 33% of table width: is a space character>
<td width="33%"> </td>
<td width="33%"> </td>
</tr><tr>
<td width="33%"> </td>
<td width="33%"> </td>
<td width="33%"> </td>
</tr></table>
which results in a table with nothing it it. Here is the same table with text in each cell. The border, cell spacing, and table width have been changed
<html>
<head></head>
<body>
<table border="1" cellpadding="4" cellspacing="1" width="525">
<tr>
<td width="33%">one</td>
<td width="33%">two</td>
<td width="33%">three</td>
</tr>
<tr>
<td width="33%">four </td>
<td width="33%">five</td>
<td width="33%">six</td>
</tr>
</table>
</body>
</html>
The web page looks like this
Figure Table with two rows and three columns
If you want to check it out, copy the code just above the Figure and paste it into Notepad. Use your mouse to click at the beginning < in the code above, hold down the left mouse button and drag to the ending >, then press CTRL C to copy. In Notepad press CTRL V to paste. Then save it as table.htm and open it in a browser.
You may have figured out by now that ordinary HTML does not make it possible to put things where you want them on a page. Even if you manage to get them where you want, if the reader resizes the browser window, all the contents get moved around. Tables are used to
The code for this table structure is shown below. The image information includes the size of the image. Only the first row of cells is commented. Notice that the border is 0 as are the other table settings. Width is 450 pixels
<table border="0" cellpadding="0" cellspacing="0" width="450"> <tr> <td width="50"> </td> <!---- 50 pixel wide cell> <td width="300"> <!---- 300 pixel wide cell> <img border="0" src="/resources/courses/ctecx104/unit02_org05_ilo03/u2s5l3-02a.gif" width="300" height="70"></td> <!---- 300 by 70 pixel image> <td width="100"> </td> <!---- 100 pixel wide cell> </tr> <tr> <td width="50"> <img border="0" src="/resources/courses/ctecx104/unit02_org05_ilo03/u2s5l3-02b.gif" width="50" height="50"></td> <td width="300"> </td> <td width="100"> <img border="0" src="/resources/courses/ctecx104/unit02_org05_ilo03/u2s5l3-02c.gif" width="100" height="50"></td> </tr> <tr> <td width="50"> </td> <td width="300"> <img border="0" src="/resources/courses/ctecx104/unit02_org05_ilo03/u2s5l3-02d.gif" width="300" height="50"></td> <td width="100"> <img border="0" src="/resources/courses/ctecx104/unit02_org05_ilo03/u2s5l3-02e.gif" width="49" height="50"></td> </tr> </table>
Here are a few more examples of web pages that are done in tables
If you need more information on tables, check this site
The purpose of this activity is to develop understanding of page layout using HTML tables.
Using a Notepad, create the following web page
Items
Location
#23
Living Room
#64
Hallway
#91
Kitchen
There is no self test for this lesson.