map


Tables

Basics table tags Table Borders Screen Resolutions Widths and Heights
Table Headers Captions Colors inside of tables Cellpadding
Cellspacing Alignment Colspan Rowspan
Tables w/in tables Bordered Backgrounds Author's notes

WHOA! Congratulations! You've come a long way if you're willing to start on tables here! But you know what? I think tables are one of the most useful 'inventions' as far as HTML goes.. why? *grrr.. had to ask a tough question did ya?* Well... for example.. without tables.. one of the pages in my site, has the potential to look like this.... *you sure you wanna look? .. POSITIVE? oh ... alright.. if you insist!* (just hit the back button on your browser to get back here) *sigh* ya made me do this. OH MAN! did you see what happened? It was PRETTY messy! I wrote all over my left hand border! Do you REALLY want someone to see that kind of mess? I didn't! That's why that page is named YUCKY!

Ok.. you ready? gotta take notes on this one.. and you MAY want to bookmark this page.. tables take a little getting use too.. but with good explainations of the tags.. you'll understand in no time..!!

First we're gonna start off with what the tags are.. and then we'll go into how to use them.. it'll make somewhat more sense that way.. *confident smile*


Basics

<table> hmm.. yup.. table!
<th> .. table header
<tr> .. table row
<td> .. table data
</td> .. close table data
</tr> .. close table cell
</table> .. hmm.. yup.. close table!

ok.. that wasn't hard.. so what's the big ole deal?!!! *wait.. don't demand your money back just yet!!!* Let's put some of that into action!

<center> <table><tr><td><font size=+3>HELLO!</font></td> <td><font color=red>my friend!</font></td></tr> <tr> <td>but you can't see the difference</td> <td>can you? </td></tr></table></center>
HELLO! my friend!
but you can't see the difference can you?

What we've done in that example.. is to create.. a table.. with two seperate rows <tr> and two seperate data 'cells' <td>. Although you can not see the individual 'cells' easily in this particular case..you can spot them by the spacing.. you can also determine the rows.. *sorry I picked a really bad example.. but hold on..I'll make it a bit clearer..lol*

*doing a bit of HTML magic here.. abracadabra!!!*


Table Borders

HELLO! my friend!
but you can't see the difference can you?

Now do you see it? .. ok.. I'll tell ya.. tables are wonderful for organizing things.. framing things!!! *they're probably my utmost favorite thing!!!* Now that you have the very BASICS of tables... there's all sorts of internal commands that have to be learned as well.. of course.. knowing me.. I'll forget half of them as I'm writing this *hee hee* and most of them I don't use myself either.. so.. let's begin..

What I did in that last example.. to make things more clear... is called "border=#" .. it goes like this:
<table border=4> .. you can put in any number you want.. the bigger the number.. the thicker the border around the table..


Screen Resolutions

There is a reason this .. so called.. computer knowledge.. is on this page.... There are different screen resolutions.. each computer is set up differently.. for different reasons.. not everyone can optomized things!!!! You have a choice, when you're working in tables, to either put things in pixels, or percentages. There's a drawback to pixels.. and here's what it is.

In pixels.. you are telling the browser to have something that is "640" pixels wide.. or.. "1000" pixels wide.. *any number would work* but you know what????? that pixel value is catrastrophe for someone who has a screen resolution of only 640.. if the value is higher than that.. then that poor person is scrolling all over the place.. *that means frustration!!!!!!!! and a frustrated viewer doesn't read and doesn't come back to your page EVER* THAT is why you SHOULD use percentages.. no matter what resolution anyone has.. they will not have to scroll.

As an actual example .. *using numbers for the logical students in the class* if your screen resolution is 640 and the guy next to you has 1024 (and I am NOT talking monitor size here) .. Let's say I have created a page using tables.. and one of my tables is set up with as being this <table border=5 width=300> .. now the guy that has the 640 resolution will see a table.. that is roughly 50% of his screen.. looks pretty good.. right? Now lean over to your neighbor.. and look at the same table on his screen.. it's gonna be just over 1/4 of his screen... and it looks dinky! All affect is totally lost on him. BUT.. if you do this instead.. <table border=5 width=50%> .. you on your 640 screen will see a table that is half your screen and so will your neighbor.. happy solution for any view.. and webmaster.

More information can be found here.


Widths & Heights

Now that we've talked about screen resolution *and if you did not read it scroll back 3 paragraphs and do so* we can talk about widths and heights in tables. As I said, there's two ways of doing it, percentages and pixels. Percentages is wonderful for widths. As an example, this page is written as a width of 99%, including the green section, on the left, which is 15% of your screen.

How to do one table without any fancy stuff, at a certain width, is like this:

<table width=75%> <tr><td> Test! </td></tr> </table>
Test!

Now, because that table is w/in the tables that I have for this page, the green section that says "test" should cover 75% of the white section of your screen, no matter the resolution. You can put any number in there that you see fit, for your width. If you put no number one of two things will happen, depending on the data within that cell.

  1. It will assume that you wish 100%.
  2. Or, if there is an image w/in that cell, it will hug the image.. nest around it, creating a frame, such as with the picture of the castle that is in the section called captions below.
You can also control the size of individual cells.. such as the green section on the left.. or with something as this.. so you can actually see how it's done: <table width=75%> <tr> <td width="20%" bgcolor="#7ec3bf"> <font color="#000000" face="arial"> This section is 20% of the three sections </td> <td width="75%" bgcolor="#307d7e"> <font color="#ffffff" face="arial"> This section is 75% of the three sections </td> <td bgcolor="#e8a317"> <font color="#000000" face="arial"> This is the remaining 5% </td> </tr> </table>
This section is 20% of the three sections This section is 75% of the three sections This is the remaining 5%

Height can be used the same way, except that I do find it a bit easier to work with pixels in that case... and I'm not forcing someone to scroll way to the left.. an example of a table height, would be like this:

<table width="60%" height="150"> <tr bgcolor="#7ec3bf"><td> <font color="#ffffff" face="arial"> Test! </td></tr> </table>
Test!

The same can be done with the <tr> and <td> cells, exactly as it was done in the example above, but just by putting height=# in the right spots.


Table Headers

Hmmm.. now I know you're wondering what happened to that <th> stuff I had mentioned.. right? well.. with a <th> we can create a header for our table

<table border=4> <th>HELLO!</th> <tr><td>I see that we've come to this</td></tr> <tr><td>part of the instructions </td></tr></table>
HELLO!
I see that we've come to this
part of the instructions

Hmmm.. a nice, neat little header.. without having to use <h1> for example..


Captions

Another aspect of tables that people should use.. is the <caption> tag.. as in this example..

<table border=15 > <caption> Neuschwanstein Castle </caption> <tr><td><center><a href="page1.html"> <IMG SRC="bandwidth.jpg" ALT="castle" BORDER="0" HEIGHT="229" WIDTH="325" border=0></a></center> </TD> </tr> </table>

Neuschwanstein Castle
castle

In the above example.. we've managed to use an image.. inside a table to give it a framed effect.. at the same time.. with the use of the <caption> tag.. PLUS we linked the image it's self to another site on the net... *one of my other pages, no need to click it.. lol*

We can also do the same thing, but with the caption under the picture by adding <caption align=bottom> .. like this:

<table border=15 > <caption align=bottom> Neuschwanstein Castle </caption> <tr><td><center> <IMG SRC="bandwidth.jpg" ALT="castle" BORDER="0" HEIGHT="229" WIDTH="325" border=0></center> </TD> </tr> </table>
Neuschwanstein Castle
castle

Color inside of tables

As you've been seeing, I've been putting color inside the tables, so you can actually 'see' what I'm talking about in most cases. You can apply color the the entire table <table bgcolor="#7ec3bf"> or to each individual cell as below:

<table border=5> <tr> <td bgcolor="#fab973">hmm? </td> <td>color? </td></tr> </table>

hmm? color?

Or to a row...

<table border=5> <tr bgcolor="#7e2217"> <td> <font color="#ffffff" face="arial"> Testing1 </td> <td> <font color="#ffffff" face="arial"> Testing2 </td> <td> <font color="#ffffff" face="arial"> Testing3 </td></tr> <tr><td> <font face="arial"> Testing4 </td> <td bgcolor="#f75d59"> <font face="arial"> Testing5 </td> <td> <font face="arial"> Testing6 </td></tr> </table>

Testing1 Testing2 Testing3
Testing4 Testing5 Testing6


Cellpadding

Cellpadding is the space that is between the stuff inside the table, and the border of the table. It applies to each and every cell equally. Here's an example using our frames free zone button.

<table border=5 cellpadding=15> <tr><td> <img src="ffz.jpg" height=40 width=60 alt="ffz"> </td> <td> <img src="ffz.jpg" height=40 width=60 alt="ffz"> </td> <td> <img src="ffz.jpg" height=40 width=60 alt="ffz"> </td> </tr> </table>
ffz ffz ffz


Cellspacing

Now cellspacing is just a bit different.. it's the amount of space between each individual cell...

<table border=10 cellspacing="20"> <tr><td> Cell 1</td> <td> Cell 2</td> <td> Cell 3 </td> </tr> </table>
Cell 1 Cell 2 Cell 3


Alignment

Now there's lots of ways to align your table, or to align the data inside the table.. let's start with the actual table first...

<center> <table border=2> <tr><td> Center outside the table tags </td></tr> </table> </center>
Center outside the table tags
Or.. <table border=2 align=center> <tr><td> Center in the table tag </td></tr> </table>
Center in the table tag

The same works with align=right and the default will be align=left

Aligning inside is a bit different. You have to make use of align and valign. Align would be your normal alignment, center or to the right.. such as this:

<table border=5 height=150 width=60%> <tr> <td> default </td> <td align=center> center </td> <td align=right> right </td></tr> </table>
default center right

valign is the verticle alignment.. how it's going to be placed in that table.. top to bottom...

<table border=5 height=150 width=60%> <tr> <td valign=top> Top </td> <td valign=middle> Middle </td> <td valign=bottom> Bottom </td></tr></table>

Top Middle Bottom

Now, it's nice to use both the align and valign to get things exactly where you want them...this as an example:

<table border=5 height=150 width=60%> <tr> <td valign=top align=center> Top and center </td> <td valign=bottom align=right> bottom and right </td></tr> </table>
Top and center bottom and right

You can do the same thing for your <tr> tag, if you wish to align your entire row the same way.


Colspan

This element allows for one cell of data to take the space up of two or more without messing up the rest of our table... you simpley specify how many cells you want it to take up:

<TABLE BORDER=3> <TR> <TD COLSPAN=4>cell 1</TD> <TD>cell 2</TD> </TR> <TR> <TD>cell 3</TD> <TD>cell 4</TD> <TD>cell 5</TD> <TD>cell 6</TD> <TD>cell 7</TD> </TR> </TABLE>
cell 1 cell 2
cell 3 cell 4 cell 5 cell 6 cell 7


Rowspan

This does the same thing, as colspan, except it specifies the amount of rows you wish to take up..

<TABLE BORDER=3> <TR> <TD ROWSPAN=2>Cell 1</TD> <TD>Cell 2</TD> <TD>Cell 3</TD> </TR> <TR> <TD>Cell 4</TD> <TD>Cell 5</TD> </TR> </TABLE>

Cell 1 Cell 2 Cell 3
Cell 4 Cell 5

Put colspan and rowspan together, and you can design yourself a nice little table.

<table border=3> <tr> <td rowspan=3> Cell 1 </td> <td colspan=2> Cell 2 </td></tr> <tr> <td>Cell 3</td> <td>Cell 4</td> </tr> <tr><td>Cell 5</td> <td>Cell 6</td> </tr> <tr><td colspan=3 align=center> Cell 7 </td> </tr></table>
Cell 1 Cell 2
Cell 3 Cell 4
Cell 5 Cell 6
Cell 7


Tables w/in tables

Technically this is called "nesting tables". What's it used for? Well, there are times, such as this page.. that you need to put tables, within tables. What's important to know here, is that you need to make sure you close all html within your tables. AND you close all your table tags correctly, including the tables, themselves. If you do not do that, Your page can vanish. It can do that anyways if your tables aren't closed correctly, but it's more difficult to figure where the problem is when you have multiple tables inside of each other... just do things carefully ;)

Ok, the 'how' to do it..

<table bgcolor="#3ea99f" border=3 width=60%> <tr><td align=center> <font color="#ffffff" face="arial"> This is my table </td> </tr> <tr><td> <center> <table width=50% bgcolor="#ffffff" border=2> <tr><td> I decided I wanted one inside the other one </td> <td> With a couple of cells </td></tr> <tr><td> and a couple of rows to demonstrate</td> <td> how to do this sort of thing</td> </tr> <tr><td colspan=2> It's up to you why you want to do it though, but it's necessary many times</td></tr></table> </td></tr> <tr><td align=center> <font color="#ffffff" face="arial"> Back to my outter table now. </td> </tr></table>

This is my table
I decided I wanted one inside the other one With a couple of cells
and a couple of rows to demonstrate how to do this sort of thing
It's up to you why you want to do it though, but it's necessary many times
Back to my outter table now.

You can put as many tables inside of tables that you want, as long as you remember that for every <tr><td> that you have open, you MUST close... and, right before every table starts, you must close the <td> tag *or the <tr> if it's going into a new row* and open a new one up.. or you will not have a page looking how you want it to.


Working w/ bordered backgrounds

I have seen several different ways of working with bordered backgrounds. They range from using <blockquote> to using <ul> to indent off of the left hand border. It works, I won't deny it, but I don't think it's the best way to do things. A simple table is not hard to build, dispite the length of this tutorial on tables. And a simple table is all that is required, for putting your homepage, on a bordered background.

Most people prefer to not write on the left hand side of their bordered background, it's got some sort of picture there already, you picked it, you like it, and you want to be able to see it.. not a bunch of stuff on it.. so here's how you do it.

<html> <head> <title> Title of your page </title> <body background="back1.jpg" text="#000000" link="#ca006b" vlink="#48cccd"> <table width=90%> <tr><td> <img src="glassbrick.gif" height=2 width=120"> </td><td> Everything you want on your page goes in this spot.. ALL HTML works inside of here </td></tr></table> </body> </html> The colors in your body tag are up to you, whatever colors you want.. but the basics of the table are the same... it comes right after the body tag.. you put everything inside the table that you want.. close the table.. close the body.. then close the html. Now that glassbrick can be downloaded here:

*right mouse click to save*
It is a transparent gif that is only 1K in size and you can adjust the height and width to suit your needs.. and to push the left *empty* cell enough to the right to make the border work. You do not need to know a lot about tables, in order to use a bordered background that you like.

If you happen to have a more complex background, it's bordered on two sides *yup it happens* it CAN be worked with, so text and images do not run onto either border. Perhaps those in the lower resolutions can not see it, but others can.. and it CAN look perfect in any resolution. A good thing to have is what's called a 'glassbrick.gif'. What it is a transparent gif, approximately 5x5, it's not very big, so it also isn't too big in K size. You can use this gif to push things over .. to take up empty <td> cells so they aren't empty. To use this glassbrick (right mouse click, 'save link as' .. to save that gif to your computer) you can adjust the height and width of it as you need. You may not need it for your page, and in most cases it's not even necessary, but it's nice to have.


Author's Notes:

Ok..I'm getting tired now.. and I think this class session is just about over.. so I'm gonna sum this up.. *bell rings in 5 minutes* There are other tags that go along with tables. You can determine the color of the border but Netscape and MSIE recognize that differently. With Netscape, your best bet is to remember to use a bgcolor in your body tag, and your tables will pick that up as your border color. Both Netscape and MSIE can use this: <table border=5 bordercolor="#cde48f">

With the new 4.x browsers out, HTML has changed a bit, and tables can now support using a background image inside the table or cell, allowing for other images or text, on top. The problem with this is that over 50% of your viewers most likely have not upgraded their browsers to a 4.x version, so they are not seeing what you want them to see. If you want to use this feature, take that into consideration. To get an image up as a background image.. :

<table border=3 cellpadding=2 background="background.jpg"> <tr><td> stuff you want in your table </td></tr></table> The same can be done with individual cells: <table border=3 cellpadding=2> <tr> <td background="background.jpg"> stuff in this table cell </td> <td> more stuff, but w/out a background. </td> </tr></table> If you want to use a background, then perhaps you could set it up so those w/out the higher browsers can view your table with just a color instead. In the higher browsers the background will take the color over.

Empty cells... as I said before, empty cells can be a bit hard to deal with.. both browsers do different things with them. In MSIE, they'll be fine, but in Netscape, they'll collapse.. so you can use the glassbrick that I talked about earlier to take space up in that cell. (right mouse click 'save link as' to save that image).

As talked about in the links tutorial...If I have an anchor link <a name=" "> in a different table, the jump will not work. Browsers see tables as one entity, so I can have one large table, with internal tables, *such as this page* and the anchor tags will work, but once I put a link to a specific anchor *on this page* on a different page, it will not work. (See links for an example using the Different Page Jump Spot link) Your best bet, if you want to do something like that, is to create small tables, and put your anchor outside of the table altogether.

Everytime you start a table, or a table data cell, you need to redo any specific HTML that you want, that is not predetermined in the body tag of your HTML document. This includes font faces, font sizes, font colors, etc. Copy/paste is a wonderful tool at times =)




| Text Size & Types | | Font Colors & Faces | | Combining Attributes |
| Color Chart | | Alignment | | Horizontal Rules | | Images |
| Links | | Lists & Blockquotes | | Tables | | Midis & Sounds |
| How to Start Your Page | | So You Want a Featured Page? |
| Guestbooks, Counters, and Other Things for your page |

| Techno Realm | |Sign Guestbook | |View Guestbook | Email |

This site created and maintained by:
Eloquent Vision Enterprises
Copyright ©1996-98 All Rights Reserved.

Eve's Realm is not responsible for this, or any banner, within this table. Click at your own risk.