[HTML]
Tables
- Important tags and attributes:
- <TABLE...>, <TH>, <TR>, <TD>
- BORDER, CELLSPACING, CELLPADDING
- COLSPAN, ROWSPAN, WIDTH
- ALIGN, VALIGN
|
Tables have straightforward uses for displaying tabular information
but they can also be used for various layout effects
(e.g. see [text]).
Tables are "clever" in that the browser
will attempt to lay them out "nicely"
depending on the size of the elements within a table's cells.
The author can give the browser advice
by setting the width of a table, or parts of a table,
either to absolute values or to fractions (%) of the page width.
The contents of a table's cell can be aligned horizontally
and vertically (VALIGN).
The table itself can also be aligned - left, right, centre -
on the page.
Tabular Information
Child | Mother | Father |
Charles | Elizabeth | Phillip |
Anne | Elizabeth | Phillip |
Edward | Elizabeth | Phillip |
Andrew | Elizabeth | Phillip |
William | Diana | Charles |
Henry | Diana | Charles |
COLSPAN and ROWSPAN
tall thin cell |
long cell |
A | B |
C | D |
- How was the following done? (Without using [view source].)
-
WIDTH
- Try resizing the window for this example.
-
TABLE WIDTH=60% |
WIDTH=20% | WIDTH=40% |
- This table has absolute widths:
-
TABLE WIDTH=500 |
WIDTH=100 | WIDTH=400 |
- WIDTH=800, try giving it less
-
Cell's WIDTH=400 |
The cell's WIDTH is set to 400 also |
Does it cause scrolling?
For printing tests:
600
|
610
|
620
|
630
|
640
|
650
|
660
|
670
|
680
|
690
|
700
|
ALIGN and VALIGN
VALIGN=top ALIGN=center |
VALIGN=bottom ALIGN=left |
VALIGN=middle ALIGN=right |
VALIGN=top ALIGN=right |
This table is aligned right but the contents
of its cells are aligned in various ways relative
to the cell boundaries.
CELLPADDING and CELLSPACING
- CELLPADDING:
-
- CELLSPACING:
-
|
Copyright ©
L. Allison,
Department of Computer Science, Monash University, Australia 3168
/ 1997