|
||
|
|
||
|
Tables are a good way of organizing lists or other information on a web page. A table is basically a method of laying out data in a series of rows and columns, like this:
| Row 1 Column 1 |
Row 1 Column 2 |
Row 1 Column 3 |
| Row 2 Column 1 |
Row 2 Column 2 |
Row 2 Column 3 |
| Row 3 Column 1 |
Row 3 Column 2 |
Row 3 Column 3 |
<TABLE></TABLE>
Of course, it all starts with the table tag. This defines the table, and everything between the tags is considered to be table data. If you put stuff between the tags that isn't formatted for tables, you may get some strange output. Okay, now let's look at some of the options for the table tag.
BORDER=#
|
|
|
CELLPADDING=#
|
|
|
CELLSPACING=#
|
|
|
BGCOLOR=color
BACKGROUND="some image"
NOWRAP
WIDTH=# or WIDTH=#%
SUMMARY="text"
ALIGN=alignment
Okay, now that we have defined a table, it's time to put some data in it. Below is a list of elements you use to create a table. Don't panic yet. I know this is confusing at first, but the upcoming examples will demonstrate the basics of making tables.
<CAPTION></CAPTION>
This defines a caption (i.e. title) for the table. The only real option is ALIGN=left/right/top/bottom which determines where the caption will be placed (on top of the table, below the table, or to the left or right of the table. If this tag is used, it MUST be the first tag following the TABLE tag.
<TR></TR>
This tag defines the beginning of a row (horizontal section) of data. There are several options you can use. It get's confusing to begin with, just hang in there.
BGCOLOR=color
ALIGN=alignment
VALIGN=alignment
<TD></TD>
This tag defines a new column of data (vertical section). There are several more options available here than for a row.
BGCOLOR=color
ALIGN=alignment
VALIGN=alignment
NOWRAP
ROWSPAN=#
COLSPAN=#
| Column 1 | Column 2 | Column 3 |
| This column has the attribute COLSPAN=3 | ||
| This row has the attribute ROWSPAN=2 | This column has the attribute COLSPAN=2 | |
| Row 3, Column 2 | Row 3, Column 3 | |
WIDTH=# or WIDTH=#%
HEIGHT=#
Okay, now let's check out how to put this all to use.
Tables can get very confusing. Don't worry, it just takes a bit to catch on. Tables can be very important to web pages, so it's good to know how to used them. For instance, my main page is layed out with one table and four sub tables inside that. We'll cover that in the next section.
First, let's look at a simple table.
| Output | HTML Coding | ||||||||||||
| Name | Age | Occupation |
| Joe Bob | 23 | Dust Collector |
| Billy Bob | 41 | Professional Killer |
| Just Bob | 135 | yes |
Let's look at this table a minute. The first step in making a table is of course to use the TABLE tag. After that, we start by declaring a row. The basic way you'll want to do tables is always the same. First, define a row. Next, define columns in that row. Simple, eh? You'll notice I haven't used any closing tags here. Some die hard HTML people may criticize you for this, but I find it helps to keep the table simple. Whatever floats your boat. A few points...Make sure you have the same number of rows in your columns, or columns in your rows (in other words, make sure your tables are rectangular) or wierd things could happen. Also, it's better to start with rows and put columns in them than to start with columns and put rows in them. I find the latter rarely formats correctly, though I don't see any reason why it shouldn't. Okay, here another example.
| Output | HTML Coding | ||||||||||||||
|
<TABLE BORDER=0 BGCOLOR=black> <TR BGCOLOR=white> <TD COLSPAN=4 ALIGN=center>Ugly Table <TR BGCOLOR=white> <TD>Joe Bob <TD>Big Bob <TD>Little Bob <TD>John Bob <TR BGCOLOR=red> <TD><FONT COLOR=white>Billy Bob</FONT> <TD ROWSPAN=2 COLSPAN=2 BGCOLOR=green>Really Big Bob <TD>Bob Bob <TR BGCOLOR=red> <TD>Rob Bob <TD>Bobby Bob </TABLE> | ||||||||||||||
This table demonstrates a few important aspects of tables. The first is how to get a colored border. I know it's a pain, but you have to make the table background the color you want the border to be, and then change the individual rows or columns to a different color, and you can't make them transparent. You'll also notice the use of the ROWSPAN and COLSPAN options. Notice that even thought the table is four columns wide, I only had to declare one column for the first row because I said it spanned four columns. Had it spanned only three columns, I would have had to declare another column to make a total of four columns.
Back: Lesson 5-Pictures and Linking | Next: More resources |
[Introduction] [Lesson 1] [Lesson 2] [Lesson 3] [Lesson 4] [Lesson 5] [Lesson 6] [More Resources]
| Send questions or comments about this site to website@socrates.math.ohio-state.edu | Copyright © 1998, Calculus&Mathematica |