Web Reference

Table attributes vs.CSS styles

Attribute

CSS

Notes

border=

border-style:

border-color:

border-width:

The border attribute controls the size of the border of the entire table. However, if the border attribute is set to 0, there will be no visible divisions between the cells. All other widths create a 1pt line around each cell.

 

The border-style (et al.) CSS can be applied to the table or cells or both.

bgcolor=

background-color:

 

background=

background-image:

background-repeat:

background-position:

background-attachment:

 

width=

width:

If the content of a cell is too big to fit within the cell, it will push the cell larger, regardless of the width/height settings.

height=

height:

As a general rule, height of a table or cell should not be specified. Let the content determine the height.

align=

text-align:

The align attribute will align the entire table if placed in the <table> tag. It will align the cell's contents if placed in a <td> tag.

 

The text-align CSS only works for contents of a cell, not the table itself.

valign=

vertical-align:

Both the valign attribute and the vertical-align CSS work only for the contents of a cell, not the table itself.

cellpadding=

padding:

The cellpadding attribute is put in the table tag and applies to all of the cells in the table.

 

The padding CSS can be applied with the td selector (which will affect all cells), or applied to specific cells with a class style.

cellspacing=

The cellspacing attribute is put in the table tag and applies to all of the cells in the table.

 

Most browsers will give tables a 2pt (or so) cellspacing by default. If you want no cellspacing, you must specify cellspacing=0.

 

The is no CSS equivalent for cellspacing.

colspan=

The is no CSS equivalent for colspan.

rowspan=

The is no CSS equivalent for rowspan.