Table AttributesThis page lists the attributes associated with table tags.
DEFAULTThis is the default table with no attributes defined.
Attributes of <TABLE>
|
BORDERThis table has a border five pixels wide. The rest of the example tables will be shown with this border. <TABLE BORDER=5> Find out how to color the borders!
CELLPADDINGThis table has a cellpadding of ten pixels. <TABLE BORDER=5 CELLPADDING=10>
CELLSPACINGThis table has a cellspacing of ten pixels. <TABLE BORDER=5 CELLSPACING=10>
For comparison, the table below has both cellspacing and cellpadding set at ten pixels.
WIDTHThis table has a width of 400 pixels. <TABLE BORDER=5 WIDTH=400>
WIDTH as a PercentageThis table has a width of 50 percent of your browser window. Try resizing the widow and notice how the width of the table is affected. <TABLE BORDER=5 WIDTH="50%">
|
Attributes of <CAPTION>
Attributes of
|
Attributes of |
Description |
---|---|
ALIGN=LEFT | CENTER | RIGHT | Horizontal alignment of contents of a cell. |
VALIGN=TOP | MIDDLE | BOTTOM | Vertical alignment of contents of a cell. |
NOTE: Alignment defined within <TH> or <TD> cells override the alignment set in <TR>. |
Acronym | Full Name |
---|---|
SGML | Standard Generalized Markup Language |
HTML | Hypertext Markup Language |
Alignment can be defined for either the entire row of cells or for individual cells. For this example, each cell is aligned individually. <TD ALIGN=**** VALIGN=****>
VALIGN=TOP -----> |
|
ALIGN=CENTER <----- |
||||||
VALIGN=BOTTOM -----> |
ALIGN=RIGHT <----- |
Attributes of |
Description |
---|---|
COLSPAN=n | The number (n) of columns a cell spans. |
ROWSPAN=n | The number (n) of rows a cell spans. |
WIDTH=? | Specify the width of the cell in pixels. |
NOWRAP | Turn off word wrapping within a cell. |
COLSPAN is used to extend cells across a column.
|
<TABLE BORDER=5> <TR> <TD>Cell 1</TD> <TD>Cell 2</TD> </TR> <TR> <TD COLSPAN=2>Cell 3</TD> </TR> </TABLE> |
The number of cells in each row must match. If there are two cells in one row and a cell in another row that spans two columns, then only that one cell can be in that row because technically it represents two cells. If there are three cells in one row and a cell in another row spans two columns, then only two cells can be in that row.
|
<TR> <TD>Cell 1</TD> <TD>Cell 2</TD> <TD>Cell 3</TD> </TR> <TR> <TD COLSPAN=2>Cell 4</TD> <TD>Cell 5</TD> </TR> |
ROWSPAN is used to extend cells through different rows. Notice again that only one cell is defined in the second row.
|
<TABLE BORDER=5> <TR> <TD ROWSPAN=2>Cell 1</TD> <TD>Cell 2</TD> </TR> <TR> <TD>Cell 3</TD> </TR> </TABLE> |
WIDTH is used to manually define the width of a cell in pixels. <TD WIDTH=?>
This cell has a width of 200 pixels. | This cell has a width of 100 pixels. |
NOWRAP is used to prevent text in a cell from being word wrapped. Use this only for short lines of text or else the table will run off the screen and you will get a horizontal scroll bar at the bottom of the browser window. <TD NOWRAP>
The text stays on one line instead of getting wrapped to the next line. | The text in this cell takes up the rest of the window, and is then wrapped to the next line. |
Go to Build Your Own Table |
Last Modified: Saturday, 25-Jul-98 10:22:08 PDT
Page URL: http://geocities.datacellar.net/SiliconValley/Vista/2823/tabattri.html