to right-align an entire row
instead of typing it for each cell.) Recent versions of the HTML standard
say we could also do to line up decimal points,
but this doesn't work in most of the browsers I've tried (it's fairly new.)
9.3 Table layout: spans & vertical alignment
You should note that is, in essence, a kind of paragraph, and as
such does not go inside ... and does not contain ... .
(Same for ..., ... .) So how do you make a heading or
other emphasis inside a table? makes a cell of regular text (with
your choice of alignment) and | makes a heading (which usually looks
bolder):
Look at my table!
| my favorite cell | top right |
| middle left | middle right |
| straddling the bottom |
View that and see what it looks like. The top left cell should look
like a heading. You could use this as a row or column heading, or just
for emphasis. I snuck another new concept in there: | .
What does it look like it did? Try changing the table to BORDER="1"
and looking at it again and it should be obvious.
COLSPAN allows you to make a cell wider (by making it count as two
or more cells spanning a horizontal area) and ROWSPAN lets you make
cells taller. Here's a new example:
Look at my table!
| X | THIS IS WIDE |
THIS IS TALL | 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 9 |
That's a little hard to understand in the source code above, but it makes
sense if you think about it a while. The table has four rows and four columns.
The first row ("X" and "THIS IS WIDE") has two cells, because one of them is
triple-width. The second row ("THIS IS TALL", "1", "2", "3") has four cells,
the first one hanging down (triple-height, it extends into the next two rows.)
Why do the third and fourth rows only have three cells each? Row 2's very tall
cell is already hanging down into Row 3 and Row 4, so we've already defined
the first column in each. Confused? Try changing that table to BORDER="1"
and it should become clearer!
In your browser, the cell that says "THIS IS TALL" has the text centered left
to right (because of ALIGN="CENTER".) And it's probably also centered top to
bottom, because that's the default behavior in most browsers. For and |
and so on, ALIGN= specifies horizontal alignment (left, right, center).
But for | (and its sisters | and | ) there's also a VALIGN= setting
that controls vertical alignment:
| VERTICAL ALIGNMENT IN TABLES |
1 BLAH BLAH BLAH |
2 BLAH BLAH |
3 BLAH BLAH BLAH BLAH |
4 BLAH BLAH |
5 BLAH BLAH |
The first three cells are top-aligned. The fourth should be centered (both
vertically and horizontally) and the fifth should be settling to the bottom.
Note that it's ALIGN="CENTER" for horizontal centering (for paragraphs, headers,
and table cells), VALIGN="MIDDLE" for vertical centering (in table cells only),
but images use to mean something like VALIGN="MIDDLE".
This is what happens when your HTML standard is accreted by a committee while
Netscape is also making up new tags.
So between COLSPAN, ROWSPAN, ALIGN, and VALIGN, you have a lot of control
over where a cell goes in a table. If you hide the border, you can use a
big table to lay out your page, making multiple columns of text, etc.
And here's a neat trick:
| TRY RESIZING THIS WINDOW A FEW TIMES! |
| ONE |
TWO |
THREE |
FOUR |
WIDTH="100%", just like in , specifies "make this 100%
the width of the window", a size which is determined by the person
looking at your page. Thus you can make your table go all the way across
someone's screen and then divide it up into chunks if you want a
columnar layout. (You can also make cells a specific percentage of the
width of the table, or specify sizes in pixels, which I'll talk about
in detail in a future installment.)
Again, don't mix , , or in with your tables. A should
not be inside ... or similar structure, and
should contain only table stuff (which means one or more ... rows,
each of which contains one or more ... | or ... | cells, which
contain text.) You may use and inside cells, and you can put a picture
inside a cell with :
Look at me! I'm Potsie! |
 |
Potsie! Potsie! Potsie! |
...and of course you could put a link in the cell too. Try making that
picture a link to one of your other practice pages.
Next time I'll talk more about tables, including how to color them in
and do other fancy formatting tricks.
(kibo)
==========================================================================
[] Send suggestions for tips & URLs to today@world.std.com.
We're also collecting links for our Web pages at eyeguy@world.std.com.
[] To contact CUSTOMER SUPPORT, send mail to support@world.std.com or
call 617-739-0202.
[] To subscribe to the "Today" mailing list, send a note saying 'subscribe
announcements' to majordomo@world.std.com.
Subscriptions to this mailing list are open to World customers only.
[] Find the big white "K" in Coolidge Corner and you've found my window!
[] Today on The World is (C) Copyright 1998 by Software Tool & Die.
Its contents may freely be redistributed as long as credit is given.
|