Table Tags

There are four tags that make up a table. Three of them are required for every table you create. There are also a number of optional attributes that control the look of a table. To confuse things even further, there are attributes that will have different effects depending on what tag they are used with. At first the tags and attributes may seem confusing, but by devoting the entire section to them, hopefully everything will seem clear by the end of the lesson.

The <TABLE> </TABLE> tags define the beginning and ending of a table. The table tag has a number of optional attributes that will effect the look of the entire table.
WIDTH= Sets the width of the table. It can either be in pixels or a percentage of the browser window. Without the width attribute, the table width will expand based on the contents. So if you have a table without a width attribute set, and nothing in the table, the width will be 0.
A single celled table with no width attribute set.

The same table with the width set to 400
BORDER= Sets the border around the table and each cell. The table border has a 3D effect. The tables that enclose all of these web pages have a border of 0 (BORDER="0"), so the table is invisible. The tables above have a border of 3 pixels (BORDER="3").
ALIGN="left | right" Aligns the table on the page. If left aligned, the table will be against the left margin and text will flow around the right side of a table, if right aligned the text flows around the left (providing the table is less than 100% wide.)
CELLSPACING= Sets the amount of space between each of the cells. The default amount depends on the browser. If the border is anything but 0, there will usually be at least 1 pixel of spacing.
not defined here
The space between cells is
the same as the border.
The same table
as above
set to 10.
CELLPADDING= Sets the amount of space between a cell's edges and it's contents.
CELLPADDING gives you some space between
the borders of a cell and its contents.
BGCOLOR= Sets the background color of the entire table. This table has a background color of #FFFFDA
Table of Contents