Tables Examples

Tables allow better positioning of text and graphics, as well as generally better control of many other aspects of page layout.


Tables can be aligned center, left, or right, and have border width, border spacing, and cell padding specified. Table 1 is centered, with a border width of 1 pixel, border spacing of 1 pixel, and cell padding of 5 pixels. This particular table does not have a maximum or minimum width specified; the browser will automatically size it.

Table 1 - Centered with Caption at the Top
Left Column, Row One Center Column, Row One Right Column, Row One
Left Column, Row Two Center Column, Row Two Right Column, Row Two
Left Column, Row Three Center Column, Row Three Right Column, Row Three

Table 2 is left aligned, set at 75% of the browser window, with a border width of 2 pixels, border spacing of 1 pixel, and cell padding of 2 pixels.

Table 2 - Left Justified with Caption at the Bottom
Left Column, Row One Center Column, Row One Right Column, Row One
Left Column, Row Two Center Column, Row Two Right Column, Row Two
Left Column, Row Three Center Column, Row Three Right Column, Row Three

Notice how the text wraps around tables that are set to left or right alignment; This allows you to create some interesting effects with graphics and other page elements.

Table 3 is right aligned, at 75% of the browser window, with a border width of 5 pixels, border spacing of 1 pixel, and cell padding of 5 pixels.

Table 3 - Right Justified with Caption at the Top
Left Column, Row One Center Column, Row One Right Column, Row One
Left Column, Row Two Center Column, Row Two Right Column, Row Two
Left Column, Row Three Center Column, Row Three Right Column, Row Three

Notice how the text wraps around tables that are set to left or right alignment; This allows you to create some interesting effects with graphics and other page elements.

Table 4 is centered, at 55% of the browser window, with a border width of 1 pixel, border spacing of 1 pixel, and cell padding of 5 pixels. In this table, though, two of the rows span multiple columns and one spans the entire table, while one column takes two rows.

Table 4 - Centered with Caption at the Top
Left Column, Row One Center Column, Row One Right Column, Row One
Left Column, Row Two Center Column, Row Two Right Column, Row Two
Left Column, Row Three Center Column, Row Three Right Column, Row Three
One Column Head, Row Four Two Columns Spanned, Row Four
Left Column, Row Five Center Column, Row Five Right Column, Row Five
Two Columns Spanned, Row Six One Column Head, Row Six
Left Column, Row Seven Center Column, Row Seven Right Column, Row Seven
All Columns Spanned, Row Eight
Left Column, Row Nine Center Column, Row Nine Right Column, Row Nine

Notice how the text doesn't wrap around tables that are centered; this breaks text into very distinct chunks.

Table 5 is centered, at 75% of the browser window, with no border or border spacing, and cell padding of 5 pixels. In this table, though, two of the rows span multple columns and one spans the entire table.

Table 5 - Centered with Caption at the Top
Left Column, Row One Center Column, Row One Right Column, Row One
Left Column, Row Two Center Column, Row Two Right Column, Row Two
Left Column, Row Three Center Column, Row Three Right Column, Row Three
One Column Head, Row Four Two Columns Spanned, Row Four
Left Column, Row Five Center Column, Row Five Right Column, Row Five
Two Columns Spanned, Row Six One Column Head, Row Six
Left Column, Row Seven Center Column, Row Seven Right Column, Row Seven
All Columns Spanned, Row Eight
Left Column, Row Nine Center Column, Row Nine Right Column, Row Nine

Table 6 is centered, at 75% of the browser window, with no border or border spacing, and cell padding of 5 pixels. We have column spanning and multiple colors in use.

Table 6 - Centered with Caption at the Top
Left Column, Row One Center Column, Row One Right Column, Row One
Left Column, Row Two Center Column, Row Two Right Column, Row Two
Left Column, Row Three Center Column, Row Three Right Column, Row Three
One Column Head, Row Four Two Columns Spanned, Row Four
Left Column, Row Five Center Column, Row Five Right Column, Row Five
Two Columns Spanned, Row Six One Column Head, Row Six
Left Column, Row Seven Center Column, Row Seven Right Column, Row Seven
All Columns Spanned, Row Eight
Left Column, Row Nine Center Column, Row Nine Right Column, Row Nine

Copyright 1998, Marc Elliot Hall, DBA Sensation! Services