<TABLE> | NN all IE all HTML 3.2 | |||||||||||||||||||
<TABLE>...</TABLE> | HTML End Tag: Required | |||||||||||||||||||
The table element is a container for additional elements that specify the content for a table. A table consists of rows and columns of content. Other elements related to the table element are caption, col, colgroup, tbody, td, tfoot, th, thead, and tr. The purpose of the table element is to define a number of visible attributes that apply to the entire table, regardless of the number of rows or columns within it. Many of these attributes can be overridden for a given row, column, or cell. The number of rows and columns is strictly a factor of the structure of tr and td elements within the table. Tables have been used for a relatively long time not only to organize rows and columns of content but also to position content. With no visible borders, table rows and columns can be set to empty space. With the advent of positionable content, the tables-for-positioning practice is not encouraged. Deeply nested tables (tables within tables) can cause problems in some browsers. Navigator 4 has severe difficulty with style sheet inheritance and overall performance in complex tables (nesting beyond three levels is asking for trouble). IE 5/Mac can inexplicably explode cell dimensions when scripts create or modify table-related elements. The simpler you keep your table structure, the more reliable your pages will be across browsers. Heavy editing of table structures in visual HTML authoring tools can leave hidden complexities (e.g., lots of empty cells) in your source code. Temporarily turn on a thin table border to see the exact row and column structure. |
||||||||||||||||||||
Example | ||||||||||||||||||||
<TABLE cols="3"> <THEAD> <TR> <TH>Time</TH><TH>Event</TH><TH>Location</TH> </TR> </THEAD> <TBODY> <TR> <TD>7:30am-5:00pm</TD><TD>Registration Open</TD><TD>Main Lobby</TD> </TR> <TR> <TD>9:00am-12:00pm</TD><TD>Keynote Speakers</TD><TD>Cypress Room</TD> </TR> </TBODY> </TABLE> |
||||||||||||||||||||
Object Model Reference | ||||||||||||||||||||
[window.]document.getElementById(elementID)
|
||||||||||||||||||||
Element-Specific Attributes | ||||||||||||||||||||
|
||||||||||||||||||||
Element-Specific Event Handler Attributes | ||||||||||||||||||||
|
align | NN all IE all HTML 3.2 |
align="where" | Optional |
Determines how the table is aligned relative to the next outermost container (usually the document body or html element). The align attribute is deprecated in HTML 4 in favor of style sheet attributes. |
|
Example | |
<TABLE align="center">...</TABLE> |
|
Value | |
Alignment constant: center | left | right. |
|
Default | |
left |
|
Object Model Reference | |
[window.]document.getElementById(elementID).align
|
background | NN 4 IE 3 HTML n/a |
background="URL" | Optional |
Specifies an image file that is used as a backdrop to the table. Unlike normal images that get loaded into browser content, a background image loads in its original size (without scaling) and tiles to fill the available table space. Smaller images download faster but are obviously repeated more often in the background. Animated GIFs are also allowable, but very distracting to the reader. When selecting a background image, be sure it is very muted in comparison to the main content so that the content stands out clearly. Background images, if used at all, should be extremely subtle. Navigator 4 can be quirky with this attribute. Be prepared to wrap your main table (without a background) inside another table element, whose background property has a graphic file assigned to it. |
|
Example | |
<TABLE background="watermark.jpg">...</TABLE> |
|
Value | |
Any valid URL to an image file, including complete and relative URLs. |
|
Default | |
None (table is transparent). |
|
Object Model Reference | |
[window.]document.getElementById(elementID).background
|
bgcolor | NN 3 IE 3 HTML 3.2 |
bgcolor="colorTripletOrName" | Optional |
Establishes a fill color (behind the text and other content) for the entire table. If you combine a bgcolor and background, any transparent areas of the background image let the background color show through. This attribute is deprecated in HTML 4 in favor of the background-color style attribute. |
|
Example | |
<TABLE bgcolor="tan">...</TABLE> |
|
Value | |
A hexadecimal triplet or plain-language color name. A setting of empty is interpreted as "#000000" (black). See Appendix A for acceptable plain-language color names. |
|
Default | |
Varies with browser, browser version, and operating system. |
|
Object Model Reference | |
[window.]document.getElementById(elementID).bgColor
|
border | NN all IE all HTML 3.2 |
border="pixelCount" | Optional |
The thickness (in pixels) of the border drawn around a table element. If you set the border attribute to any value, browsers by default render narrow borders around each of the cells inside the table. With a table element's border showing, the thickness of internal borders between cells is defined by the cellspacing attribute of the table element. If you include only the border attribute without assigning any value to it, the browser renders default-sized borders around the entire table and between cells, unless overridden by other attributes. Browsers render the border in a 3-D style, with the border appearing to be raised around the flat content in the cells. Numerous other attributes affect the look of the border, including: bordercolor, bordercolordark, bordercolorlight, frame, and rules. The type of border rendered for tables is different from the borders defined by style sheet rules. You get better control of the border look by using the dedicated attributes of the table element. |
|
Example | |
<TABLE border="1">...</TABLE> |
|
Value | |
A positive integer value. |
|
Default | |
0 |
|
Object Model Reference | |
[window.]document.getElementById(elementID).border
|
bordercolor | NN 4 IE 3 HTML n/a |
bordercolor="colorTripletOrName" | Optional |
The colors used to render some of the pixels that create the illusion of borders around cells and the entire table. The border attribute must have a nonzero value assigned for the color to appear. The 3-D effect of borders in is created by careful positioning of light (or white) and dark lines around the page's background or default color (see Figure 8-4). Standard colors are usually shades of gray and white, depending on the browser. Applying color to a table border has a different effect in Navigator and Internet Explorer. In Navigator, the color is applied to what is normally the darker of the two shades used to create the border. Moreover, Navigator automatically adjusts the darkness of some of the lines to enhance the 3-D effect of the border. In contrast, Internet Explorer applies the color to all lines that make up the border. The net effect is to flatten the 3-D effect (refer to the bordercolordark and bordercolorlight attributes to color borders and maintain the 3-D effect in IE). |
|
Example | |
<TABLE bordercolor="green" border="2">...</TABLE> |
|
Value | |
A hexadecimal triplet or plain-language color name. A setting of empty is interpreted as "#000000" (black). See Appendix A for acceptable plain-language color names. |
|
Default | |
Varies with browser and operating system. |
|
Object Model Reference | |
[window.]document.getElementById(elementID).borderColor
|
bordercolordark, bordercolorlight | NN n/a IE 3 HTML n/a |
bordercolordark="colorTripletOrName" bordercolorlight="colorTripletOrName" | Optional |
The 3-D effect of table borders in Internet Explorer is created by careful positioning of light and dark lines around the page's background or default color (see Figure 8-4). You can independently control the colors used for the dark and light lines by assigning values to the bordercolordark and bordercolorlight attributes. The border attribute must have a nonzero value assigned for the colors to appear. Typically, you should assign complementary colors to the pair of attributes. There is also no rule that says you must assign a dark color to bordercolordark. The attributes merely control a well-defined set of lines so you can predict which lines of the border change with each attribute. To achieve the identical look in Navigator and IE, you must determine the complementary colors that Navigator uses for its 3-D effect from the bordercolor attribute. Then assign those values to the bordercolordark and bordercolorlight attributes. You may place all three attributes in the same <TABLE> tag. |
|
Example | |
<TABLE bordercolordark="darkred" bordercolorlight="salmon" border="3">... </TABLE> |
|
Value | |
A hexadecimal triplet or plain-language color name. A setting of empty is interpreted as "#000000" (black). See Appendix A for acceptable plain-language color names. |
|
Default | |
Varies with operating system. |
|
Object Model Reference | |
[window.]document.getElementById(elementID).borderColorDark [window.]document.getElementById(elementID).borderColorLight |
cellpadding | NN all IE 3 HTML 3.2 |
cellpadding="length" | Optional |
The amount of empty space between the border of a table cell and the content of the cell. Note that this attribute applies to space inside a cell. Without setting this attribute, most browsers render text content so that its leftmost pixels abut the left edge of the cell. If the table displays borders, adding a few pixels of breathing space between the border edge and the content makes the content more readable. Large padding may also be desirable in some design instances. This attribute is not as noticeable when the table does not display borders (in which case the cellspacing attribute can assist in adjusting the space between cells). |
|
Example | |
<TABLE border="2" cellpadding="3">...</TABLE> |
|
Value | |
Any length value in pixels or percentage of available space. Percentage values are based on the total available space in the horizontal and vertical dimensions of the cell. For example, a value of 10% means that the left and right padding will each be 5% of the total width of the cell; the top and bottom padding will each be 5% of the total height of the cell. |
|
Default | |
0 |
|
Object Model Reference | |
[window.]document.getElementById(elementID).cellPadding
|
cellspacing | NN all IE 3 HTML 3.2 |
cellspacing="length" | Optional |
The amount of empty space between the outer edges of each table cell. If you set the border attribute of the table element to any positive integer value, the effect of setting cellspacing is to define the thickness of borders rendered between cells. Even without a visible border, the readability of a table often benefits from cell spacing. |
|
Example | |
<TABLE border="2" cellspacing="10">...</TABLE> |
|
Value | |
Any positive integer. |
|
Default | |
0 (no table border); 2 (with table border). |
|
Object Model Reference | |
[window.]document.getElementById(elementID).cellSpacing
|
cols | NN 4 IE 3 HTML n/a |
cols="columnCount" | Optional |
The number of columns of the table. The HTML specification never adopted this attribute. In HTML 4, the functionality of this attribute is covered by the colgroup and col elements. In the meantime, the cols attribute is recognized by older and current browsers. The attribute assists the browser in preparation for rendering the table. Without this attribute, the browser relies on its interpretation of all downloaded tr and td elements to determine how the table is to be divided. |
|
Example | |
<TABLE cols="4">...</TABLE> |
|
Value | |
Any positive integer. |
|
Default | |
None. |
|
Object Model Reference | |
[window.]document.getElementById(elementID).cols
|
datapagesize | NN n/a IE 4 HTML n/a |
datapagesize="recordCount" | Optional |
Used with IE data binding, this attribute advises the browser how many instances of a table row must be rendered to accommodate the number of data source records set by this attribute. A common application is setting a table cell to display a text input element whose datafld attribute is bound to a particular column of the data source (the datasrc is set in the table element). If the datapagesize attribute is set to 5, the browser must display five rows of the table (but the row is specified in the HTML only once). |
|
Example | |
<TABLE datasrc="DBSRC3" datapagesize="5"> <TR> <TD><INPUT type="text" datafld="stockNum"></TD> <TD><INPUT type="text" datafld="qtyOnHand"></TD> </TR> </TABLE> |
|
Value | |
Any positive integer. |
|
Default | |
None. |
|
Object Model Reference | |
[window.]document.getElementById(elementID).dataPageSize
|
datasrc | NN n/a IE 4 HTML n/a |
datasrc="dataSourceName" | Optional |
Used with IE data binding to specify the ID of the page's object element that loads the data source object for remote data access. Content from the data source is specified via the datafld attribute. A block of contiguous records can be rendered in the table when you also set the datapagesize attribute of the table. Works only with text file data sources in IE 5/Mac. |
|
Example | |
<TABLE datasrc="DBSRC3" datapagesize="5">...</TABLE> |
|
Value | |
Case-sensitive identifier. |
|
Default | |
None. |
|
Object Model Reference | |
[window.]document.getElementById(elementID).dataSrc
|
dir | NN 6 IE 5 HTML 4 |
dir="direction" | Optional |
The direction of character rendering for the element's text when the characters are not governed by inherent directionality according to the Unicode standard. Character rendering is either left-to-right or right-to-left. This attribute is usually set in concert with the lang attribute; it must be used to specify a character-rendering direction that overrides the current direction. |
|
Example | |
<A lang="ar" dir="rtl">Some Unicode Arabic text characters here</A>
|
|
Value | |
ltr | rtl |
|
Default | |
ltr |
frame | NN 6 IE 3 HTML 4 |
frame="frameConstant" | Optional |
Defines which (if any) sides of a table's outer border (set with the border attribute) are rendered. This attribute does not affect the interior borders between cells. Including the border attribute without assigning any value to it is the same as setting the frame attribute to border. All settings can be replicated with CSS border-related attributes if you prefer. |
|
Example | |
<TABLE border="3" frame="void">...</TABLE> |
|
Value | |
Any one case-insensitive frame constant: |
|
Default | |
Navigator: void (when border=0); border (when border is any other value). Internet Explorer: border. |
|
Object Model Reference | |
[window.]document.getElementById(elementID).frame
|
height, width | NN all IE 3 HTML 3.2 (width) |
height="length" width="length" | Optional |
The rectangular dimensions of a table that may be different from the default size as calculated by the browser. When the values for these attributes are less than the minimum space required to render the table cell content, the browser overrides the attribute settings to make sure that all content appears, even if it means that text lines word-wrap. You can also stretch the dimensions of a table beyond the browser-calculated dimensions. Extra whitespace appears inside table cells to make up the difference. If you specify just one attribute, the browser performs the necessary calculations to automatically adjust the dimension along the other axis. Note that the height attribute is not in the HTML specification. The assumption there is that the table height is calculated by the browser to best show all cell content given either the default or attribute-established width. Because different browsers on different operating systems can render text content in varying relative font sizes, it is not unusual to let the height of a table be calculated by the browser. |
|
Example | |
<TABLE width="80%">...</TABLE> |
|
Value | |
Any length value in pixels or percentage of available space. |
|
Default | |
Governed by content, but width not to exceed 100% of the next outermost container. IE does accept percentage values beyond 100%, which may cause the table's container to display scroll bars and perhaps disturb the graphical integrity of the layout design. |
|
Object Model Reference | |
[window.]document.getElementById(elementID).height [window.]document.getElementById(elementID).width |
hspace, vspace | NN 6 IE n/a HTML n/a |
hspace="pixels" vspace="pixels" | Optional |
Inserts transparent padding outside the edges of the entire table on the page. Use CSS-padding-related attributes instead. Note that Netscape 6 responds to these table element attributes only in "quirks" mode (see DOCTYPE element). |
|
Example | |
<TABLE hspace="20" vspace="40">...</TABLE> |
|
Value | |
Integer pixel count. |
|
Default | |
0 |
lang | NN 3 IE 4 HTML 4 |
lang="languageCode" | Optional |
The language being used for the element's attribute values and content. A browser can use this information to assist in proper rendering of content with respect to details such as treatment of ligatures (when supported by a particular font or required by a written language), quotation marks, and hyphenation. Other applications and search engines might use this information to aid the selection of spell-checking dictionaries and the creation of indices. |
|
Example | |
<SPAN lang="de">Deutsche Bundesbahn</SPAN> |
|
Value | |
Case-insensitive language code. |
|
Default | |
Browser default. |
|
Object Model Reference | |
[window.]document.getElementById(elementID).lang
|
layout | NN 6 IE n/a HTML n/a |
layout="layoutType" | Optional |
Controls the table-layout-rendering algorithm. A value of fixed directs the browser to size the table and cells according to explicit height and width settings, rather than respecting content size minimums. This attribute mimics the table-layout CSS attribute. |
|
Example | |
<TABLE layout="fixed" width="500">...</TABLE> |
|
Value | |
Constant values: auto | fixed. |
|
Default | |
auto |
rules | NN 7 IE 3 HTML 4 |
rules="rulesConstant" | Optional |
Defines where (if at all) interior borders between cells are rendered by the browser. In addition to setting the table to draw borders to turn the cells into a matrix, you can also set borders to be drawn only to separate rows, columns, or any sanctioned cell grouping (thead, tbody, tfoot, colgroup, or col). The border attribute must be presenteither as a Boolean or set to a specific border sizefor any cell borders to be drawn. IE 5/Mac leaves gaps in inter-cell borders where rules are removed. |
|
Example | |
<TABLE border="3" rules="groups">...</TABLE> |
|
Value | |
Any one case-insensitive rules constant: |
|
Default | |
none (when border=0); all (when border is any other value). |
|
Object Model Reference | |
[window.]document.getElementById(elementID).rules
|
summary | NN 6 IE 6 HTML 4 |
summary="text" | Optional |
A textual description of the table, including, but not limited to, instructions that nonvisual browsers might follow to describe the purpose and organization of the table data. The Properties choice for Netscape 6's context menu for this element displays a small window that includes an active link to the URL assigned to the attribute. Version 6 browsers provide no other functionality for this attribute. |
|
Example | |
<TABLE summary="Order form for entry of up to five products.">...</TABLE> |
|
Value | |
Any quoted string of characters. |
|
Default | |
None. |
vspace | |
See hspace. |
width | |
See height. |