TABLES are used to present data in rows and columns on a web page. They can be used to anchor text and images on a page.
All table structures begin with the TABLE tag, closing tags are required for all table related tags. Beginners should also avoid building a table within a table.
•WIDTH=measurements are in pixels or percentage. For best results, because most surfers do not use full view when browsing, do not exceed a 500 or 600 pixel setting. Or try a percentage setting of 90%.
•BORDER=border settings are a matter of preference. Experiment and decide which works best for you. Zero is no border. One is a single border. Two is 3 dimensional. Successive numbers increase the thickness of the 3 dimensional effect.
•CELLPADDING=specifies the distance in pixels of the text or image from the inside wall of a cell.
•CELLSPACING=specifies in pixels, the spacing between cells in a table.
•BGCOLOR=sets and overall background color for the entire table. You can also use bgcolor in row and cell tags to produce multi color effects.
•BACKGROUND=for adding a background image to the table. You can use style sheets for this setting, but because of incompatibilty problems with Netscape it is best to use this method.
Attributes within the row tag:
•ALIGN=horizontal alignment. Choices are left, right or center.
•VALIGN=vertical alignment. Choices are top, middle or bottom.
•CELL OR COLUMN TAG=used to define the cells in a row.
Attributes within the column tag:
•ALIGN=horizontal alignment. Choices are left, right or center.
•VALIGN=vertical alignment. Choices are top, middle or bottom.
•BGCOLOR=set individual background colors for cells.
•WIDTH=measurements in pixels or percentage.
This is the basic code for the following table: (single row - 2 column)
From the first example, lets change some of the coding and see how it affects the appearance fo the table.
The changes made:
• Setting the width of the table to 400 from 200.
*Removing the Border*
Column One
Column Two
Column One
Column Two
Column One
Column Two
Column One
Column Two
• Changed border setting to 3 for a three dimensional effect.
• Added the align="center" attribute to both cells.
Flag
Flag
One of the hardest things for a beginner in HTML to do, is to control text on a page. The following code sequence can be used to anchor a paragraph on a web page, centered and left justified.
The code:
The use of tables in a document can be confusing at first but,
The use of tables in a document can be confusing at first but, if you remember a few simple rules, they can be mastered very quickly. Always use pairs of tags.
Spanning is a very useful table creation tool. Cell spanning allows you to alter the size of cells to your own needs.
Use the COLSPAN= attribute to span one cell across two or more existing cells.
Use the ROWSPAN= attribute to span one cell across two or more existing cells.
Notice Cell C is now SPANNED across two cells and ROWS.
Cell A
Cell B
Cell C
Cell D
Cell F
Notice Cell D is SPANNED across two cells.
Cell A
Cell B
Cell C
Cell F
Cell A
Cell B
Cell C
Cell D
Cell E
Cell A
Cell B
Cell C
Cell D
Cell E
For browser compatibility color settings in tables should use the inline bgcolor attribute:
bgcolor="red"
bgcolor="#ff0000"
Tags that accept the bgcolor attribute are:
(IE)
The code below shows how to set the color within the tags that accept the bgcolor attribute. Heading
Column 1
Column 2
Heading
Column 1
Column 2