|
|
|
Tables are great for visual distribution of text and graphics. This page has tips on using tables in HTML. You may also want to see keyboard shortcuts specific to tables as used in Microsoft FrontPage. Table AttributesSummaryThe SUMMARY attribute of the <table> tag summarizes the tables purpose, content, and structure. Non-visual browsers render the summary into speech or Braille. A briefer description can be specified by the <caption> tag. <table border="1"
width="70%"
summary="This table merely demonstrates the SUMMARY attribute of the TABLE tag.">
<caption>Example For SUMMARY attribute</caption>
<tr>
<td width="50%"> </td>
<td width="50%"> </td>
</tr>
</table>
AlignThe ALIGN attribute is deprecated but specifies either left (the default), center, or right.
Spacing and PaddingTable spacing and padding is set with attributes of the <table> tag:
Frames and RulesTable frames and rules are set with attributes of the <table> tag.
This is a 3x3 table with the top row merged, but it is showing only the left and right sides of the frame, and only the horizontal rules:
Table and Cell AttributesColorsBackground and border colors may be set for the entire table and/or for individual cells. In this example, the entire table background is set to a gray:
In this example, different cells are modified. Note that the BORDERCOLOR, BORDERCOLORLIGHT, and BORDERCOLORDARK attributes of the <td> tag are not part of the HTML specifications but are supported by MS FrontPage and Internet Explorer.
WidthThe WIDTH attribute specifies pixels (eg "100") or percentage (eg "80%"). The default is "100%". Dynamic tables have dimensions set in percentage of its container. Dynamic tables are especially good for text. The following table dynamically adjusts to the user's browser size:
Watch your table width carefully when you set them in lists or within other tables. When the width of an object in HTML is set in percentage, it is a percentage relative to the object immediately containing the object. The container may be the browser window, a frameset, or a cell of another table. In this example, the tables are set at 100% width (of the browser). However some browsers may not realize that because it is part of a <blockquote> (or a list), its left end starts a bit further to the right, thus the right end of the table may disappear:
Fixed tables have dimensions set in pixels. Fixed tables are especially good for relatively precise graphical arrangement. The following table remains a fixed size regardless of the user's browser size:
Fixed and dynamic cells may be combined within a table. In the following table, the cells on the end are fixed and only the center cell dynamically changes in size depending on the user's browser size:
Tables may be nested. Typically the outer table is used for formatting the display and the inner table is for showing some data. EG: The outer table is used to make a central column.
This table has cells, each of which is 25% of the browser width: Inside the above table I have placed an inner table. The inner table has cells, each of which is 33% of the cell enclosing the entire inner table, i.e. each of its cells is 25% divided by 3 or 8.3% of the browser width.
Alternatives to TablesDon't over use tables. Consider using the following alternatives:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||