Site hosted by Angelfire.com: Build your free website today!
Contents

* Getting started
* DOCTYPE declaration
* META & TITLE tags
* Colour & layout
* Text organization
* Images
- Tables
* Validation

[Home]
Tables are a very good way to present information in a page. They provide great flexibility and easier navigation.

Although tables are block-level elements, their building blocks [rows and data cells] are not true block-level elements. For example, a data cell can contain the <P> tag, but not the <H#> tag. A row should never contain any text on its own, always use data cells within a row.

IMHO, tables are superior to frames because they load quickly, they're supported by all browsers but Lynx and the really ancient IE and NS [and they still look okay in them] and because, well, frames are a pain in the you-know-what. That said, without further ado I present to you the `final frontier': HTML tables ;).
To start a table, use the <TABLE> tag, to end a table, use the </TABLE> tag. No, that's not all :) There are quite a few attributes you can specify in a table: So now you have specified all this neat stuff for the appearance of your table. Now you have to start a new table row. You do that by typing <TR> after your TABLE start tag. Now, you can add some attributes to the row that govern the way text will be aligned in the row's data cells: You can override this alignment by specifying a different one within a data cell in that row [the attributes are the same] And remember, before you add any data cells, close the row by adding </TR>. Data cells will go in between the start and end tags for the row. Remember this! You are not allowed to have any row or data cell tags hanging around without being closed, or outside the table.

So what are those elusive data cells? Well they're the places where your content will go. Hey, you can even make a new table within a data cell, and another table within *that* table's data cell.. and so on. You can nest as many tables as you want. How do you make a data cell? Just type <TD></TD> and all your content in between those two tags. Now, don't worry, I know all this is a mouthful, but I'l provide elaborate examples with code samples later on. Just hang in there :)

What else can you do with data cells? Well, you can override text alignment, as I mentioned before. You can also have a table whose data cells are all different colours by using the BGCOLOR attribute. It's usually a very good idea to specify the widths of your data cells using the WIDTH attribute, because that way you can ensure that they are equal in size - otherwise you might get a skewed-looking table.

There's a special kind of data cell called a header cell - <TH></TH> - when you type in a header cell, the text automagically turns bold.

If you want a data cell to span more than one column, you can use the COLSPAN attribute, specifying the number of columns the data cell should span. This number cannot, of course, be more than the number of columns you already have.

And finally, you can also specify a caption for your table - this is a line of text that describes your table [or does whatever you want it to do, really]. The tag to use is <CAPTION> and it must immediately follow the TABLE start tag; you cannot include it anywhere else. It will default to central alignment, which you can override using the ALIGN attribute and align it left or right. And yeah, you have to close the CAPTION tag too :)

Okay, well, I think we could all stand a few examples right about now, couldn't we :)
<TABLE BORDER="5" CELLPADDING="5" CELLSPACING="5" WIDTH="50%" BGCOLOR="#FF00FF" ALIGN="center">

<CAPTION ALIGN="left">See where I put the caption? See what it does?</CAPTION>

<TR ALIGN="left" VALIGN="top">
<TH><FONT COLOR="#000000"> This is Header 1</FONT></TH>
<TH ALIGN="right" VALIGN="bottom"><FONT COLOR="#000000">This is Header 2</FONT></TH>
<TH BGCOLOR="#996633">This is Header 3</TH>
</TR>

<TR ALIGN="center" VALIGN="middle">
<TD ALIGN="left" VALIGN="top"><FONT COLOR="#000000">See how I'm changing the font?</TD>
<TD>That's the correct way to do it- FONT is an inline element and should never include a block-level element</TD>
<TD>Imagine the possibilities with tables!</TD>
</TR>

<TR ALIGN="right" VALIGN="bottom">
<TD COLSPAN=3><FONT COLOR="#000000"<This example demonstrates most of the tags and attributes we talked about. The next one will deal with nested tables</FONT></TD>
</TR>

</TABLE>
See where I put the caption? See what it does?
This Header 1This is Header 2This is Header 3
See how I'm changing the font?That's the correct way to do it- FONT is an inline element and should never include a block-level element Imagine the possibilities with tables!
This example demonstrates most of the tags and attributes we talked about. The next one will deal with nested tables
<TABLE BORDER="8" CELLPADDING="8" CELLSPACING="8" WIDTH="100%" ALIGN="center">
<TR><TD>

<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="3" WIDTH="70%"><TR>
<TD>This is the first nested table.</TD>
<TD>See how much attention you have to pay to all these tags?</TD>
</TR></TABLE>

</TD>
<TD>

<TABLE BORDER="2" CELLPADDING="2" CELLSPACING="2" WIDTH="30%"><TR>
<TD>All tags must be closed properly</TD>
<TD>The worst thing you could ever do is leave a TABLE tag open</TD>
<TD>That produces some majorly weird stuff</TD>
</TR></TABLE>

</TD></TR>
<TR><TD COLSPAN=2>

<TABLE BORDER="3" CELLPADDING="0" CELLSPACING="0" WIDTH="100%"><TR>
<TD>Well this is just a silly example, of course. But there's all sorts of neat stuff to be done with tables</TD>
<TD>Just think of all the crazy colours :)</TD></TR>
<TR><TD COLSPAN=2>The next example deals with how to organize pictures with tables</TD></TR></TABLE>

</TD></TR></TABLE>
This is the first nested table.See how much attention you have to pay to all these tags?
All tags must be closed properlyThe worst thing you could ever do is leave a TABLE tag openThat produces some majorly weird stuff
Well this is just a silly example, of course. But there's all sorts of neat stuff to be done with tablesJust think of all the crazy colours :)
The next example deals with how to organize pictures with tables
<TABLE BORDER="0" ALIGN="center" WIDTH="225" CELLPADDING="0" CELLSPACING="0">
<TR ALIGN="center" VALIGN="middle">
<TD><IMG SRC="images/tne40.jpg" ALT="Keanu Reeves is Neo" BORDER=0 HEIGHT=75 WIDTH=75></TD>
<TD><IMG SRC="images/tmo1.gif" ALT="Laurence Fishburne is Morpheus" BORDER=0 HEIGHT=75 WIDTH=100></TD>
<TD><IMG SRC="images/ttr32.jpg" ALT="Carrie-Anne Moss is Trinity" BORDER=0 HEIGHT=75 WIDTH=50></TD>
</TR>
<TR ALIGN="left" VALIGN="top">
<TD COLSPAN=3>See how nicely you can organize pictures? And this is just horizontally</TD> </TR>
</TABLE>
Keanu Reeves is NeoLaurence Fishburne is MorpheusCarrie-Anne Moss is Trinity
See how nicely you can organize pictures? And this is just horizontally!

[Previous page] [Next page]