HTML Table Tags
Tables: (careful: not all browsers support tables)
- To make a TABLE, use this tag set:
- <TABLE> ... </TABLE>
- For Table Rows, use the tag set:
- <TR> ... </TR>
- For Table Data, use the tag set:
- <TD> ... </TD>
- For a Table Header, use the tag set:
- <TH> ... </TH>, which is the same as TD, but data is bolded.
- For a table CAPTION, use the tag set:
- <CAPTION> ... </CAPTION>
Example of Table:
Store Hours
Day |
Hours |
Monday-Friday |
8-8 |
Saturday-Sunday |
10-7 |
This was coded as:
<TABLE>
<CAPTION>Store Hours</CAPTION>
<TR>
<TH>Day</TH>
<TH>Hours</TH>
</TR>
<TR>
<TD>Monday-Friday</TD>
<TD>8-8</TD>
</TR>
<TR>
<TD>Saturday-Sunday</TD>
<TD>10-7</TD>
</TR>
</TABLE>
Table [Basic] Attributes:
- <TABLE BORDER=X>
- Draws a border of width=x pixels around all table cells
- <TABLE CELLSPACING=X>
- The amount of space in pixels inserted between individual cells in a table
- <TABLE CELLPADDING=X>
- The amount of space in pixels between the border of the cell and the contents of the cell.
- <TABLE WIDTH=X_or_%>
- The width of the table, in absolute pixel width or in a percentage of the document width.
- <TR_or_TD_or_TH ALIGN=LEFT_or_CENTER_or_RIGHT>
- Alignment of the data inside the cell
- <TR_or_TD_or_TH VALIGN=TOP_or_MIDDLE_or_BOTTOM>
- Vertical alignment of the data within the cell
As example:
Store Hours
Day |
Hours |
Monday-Friday |
8-8 |
Saturday-Sunday |
10-7 |
would be coded as:
<TABLE BORDER=3 CELLSPACING=20 CELLPADDING=10 WIDTH=90%>
<CAPTION>Store Hours</CAPTION>
<TR ALIGN=CENTER>
<TH>Day</TH>
<TH>Hours</TH>
</TR>
<TR ALIGN=LEFT>
<TD>Monday-Friday</TD>
<TD>8-8</TD>
</TR>
<TR>
<TD>Saturday-Sunday</TD>
<TD ALIGN=RIGHT>10-7</TD>
</TR>
</TABLE>