|
Website Blueprints/ pg. 7 CHAPTER 6:
TABLES VS. FRAMES Now with all your individual elements at the reader, how the heck do you pull it all together? Frames or tables? Tables or frames? Let's find out, shall we? Table Basics You might want to learn about how to create frames before you learn about how to use them. There are only three tags that are essential to create a table (for the other two, see Chapter 10 of HTML Is Your Friend). These are the <table>, <tr>, and <td> tags.
|
|||||
| <html> <table border=1 cellpadding=1 cellspacing=1> <!--the other table tags go here--> </table> </html> |
|||||
|
To create a row of data cells, use the <tr> tag. Each row you want to make is represented by a <tr> tag and its end tag. There is really only one important attribute for the <tr> tag is the bgcolor= attribute, which defines the background color for the entire row. The values are in hexadecimal. |
|||||
| <html> <table border=1 cellpadding=1 cellspacing=1> <tr><!--other table tags go here--></tr> <tr><!--another row--></tr> <!--there are two rows in this table--> </table> </html> |
|||||
|
The final tag to worry about for a table is the <td> tag. This tag defines the data cell, and in effect, a column. You see, when you create a data cell in one row, there is a space reserved for a corresponding cell in all the other rows, just like a column.
|
|||||
| <html> <table border=1 cellpadding=1 cellspacing=1> <tr> <td bgcolor=#00dddd width=75>First row, first cell</td> <td width=100 valign=top>First row, second cell</td> </tr> <tr> <td colspan=2 align=right>Second row</td> </tr> </table> </html> |
|||||
Personally, I love tables. But not the fact that tables have a very ugly shaded border by default. So I turn it off, by setting the border= attribute to zero. I can't stand sites with that border. |
Table Design Tables, are by far, the best way in HTML to precisely control space, because of the ability for you to control the height and width of each cell. And the best part about tables is the fact that the reader doesn't have to see it in the end, because of the wonderful border= attribute. Just set it to zero, and the reader doesn't know about the scaffolding that keeps the site together.
|
||||
|
Frame Basics Learning frames is easy. Only three easy to learn tags, the <frameset>, <frame>, and <noframe> tags (see Chapter 9 of HTML Is Your Friend).
|
|||||
| <html> <head></head> <frameset rows="55, 50%, *"> ...other frame tags go here... </frameset> </html> |
|||||
|
In the code above, I just coded for three rows, the first column is 55 pixels high, the second is 50% of the window, and the last row takes up the remainding space. The other frame tags go in between the start and end tags. They have no end tag, so don't worry about it. The next tag is the <frame> tag. It's function is to tell the browser what HTML file to display inside the <frame> tag's frame. You see, in frames there is no content. You prepare the content in other HTML documents, which are placed into the frames by the <frameset> tags.
|
|||||
| <html> <head></head> <frameset rows="55, 50%, *"> <frame src="blank.htm"> <frame src="qmain.htm" name=main> <frame src="qlepton.htm" name=lepton> </frameset> </html> |
|||||
|
The final tag is mainly for the concern of the reader. The <noframe> tag allows you to define content for people who don't have frames-capable browsers. You place the <noframe> tag within the <frameset> tag and end-tag. Simply place the content you want non-frames capable readers to see between the <noframe> tag and end-tag, and voila! That's that. You should, nay, you must include this tag whenever you use frames, however infrequently that is. |
|||||
| <html> <head></head> <frameset rows="55, 50%, *"> <frame src="blank.htm"> <frame src="qmain.htm" name=main> <frame src="qlepton.htm" name=lepton> <noframe>Sorry, but I used frames. Please go the <a href=qmain.htm>noframes</a> version.</noframe> </frameset> </html> |
|||||
I don't like it when a different site ends up in your frames, because the coder forgot to specify the target. |
Now it's time to see the frames in action!
Frames can be useful for space control. But they're not really meant for layout. Frames simply cannot offer the versatility of tables, since you're just cutting up the window, instead of using the space. Each frame acts as an independent window, which makes things difficult in terms of hyperlinks. For each hyperlink, you have to be much more specific (see Chapter 6 of HTML Is Your Friend).
You know now about tables and frames, how to use them, how to create them. It's time to go on to work on compatability issues.
|
||||