HTML and CSS Reference
In-Depth Information
Required Attributes
There are no required attributes for the table element.
Optional Attributes
In addition to the global attributes, the table element has the following optional attribute:
border : indicates that its table element is not being used for layout. The value of
this attribute must be either an empty string or "1".
To be frank, the inclusion of this presentational attribute somewhat muddies the waters regarding proper
use of the table element. According to the specification, the entirely optional border attribute may be
used to explicitly declare that the table element is not being used for layout. But, as you know from earlier
in this section, tables are not to be used for layout anyway.
The HTML5 specification does indicate, however, that certain user agents use this attribute to determine
whether or not to draw borders around cells within the table. For completion's sake, we've included
information about this attribute but you'll rarely need to use it.
In previous versions of the HTML specification, the table element had a number of
presentational attributes: width , align , cellpadding , cellspacing , etc. Although
these attributes have been rendered obsolete in the HTML5 specification, you may still
encounter them in the wild. These attributes were at one time valid but are now
deprecated and shouldn't be used.
tr
Tables are composed of cells organized into rows and columns. In HTML, you mark up tables one row at a
time using the tr element which is short for “table row.”
Listing 7-2. A basic table with a single row
<table>
<tr>
<td>Utility Belts</td>
</tr>
</table>
A tr element must have a start tag. The end tag, however, is optional if the tr element's next immediate
sibling is another tr element or if its parent contains no further content. For example, Listing 7-3 shows a
table with tr end tags omitted.
Listing 7-3. A table with an end-tag omitted row
<table>
<tr>
<td>Utility Belts</td>
</table>
 
Search WWH ::




Custom Search