Webmaster

HTML : Tables
Contents ]
Jérôme Versavel

Border and Size

As with many HTML elements, tables can be customised using a whole series of attributes.

The default rendering for a table makes its borders apparent. The <TABLE> tag accepts three attributes to control these borders:

  • BORDER, which sets the thickness of the visible border in pixels.

  • CELLSPACING, which sets the spacing between cells of a table in pixels.

  • CELLPADING, which sets the padding space between a cell border and its content in pixels.

Invisible tables. If you use tables for complex page layout, it is preferable to leave these attributes with a value of 0. It can also be useful to assign a value of 1 to the BORDER attribute during development, particularly if you are dealing with nested tables. This will give you a better idea of the exact position of the various cells and it will make the layout process easier.

The <TABLE> tag will also accept the WIDTH and HEIGHT attributes which set the table width and height. When no width is specified, it is determined by the browser:

  • The width can be specified with an absolute value (<TABLE WIDTH="200">, for 200 pixels) or as a percentage of the page's available horizontal space (<TABLE WIDTH="80%">).

  • The height is only a minimum value. The actual table height can be greater than the indicated value if it is too small to hold the content.

The <TD> and <TH> tags can be subject to the same WIDTH and HEIGHT parameters.



  1   2   3   4   5   6