This section briefly describes the important behaviour, attributes, and rules for each of the common HTML elements.
Other sorts of links are also possible, but are beyond the scope of this book.
The value of an href attribute can be: a URL, which specifies a separate web page to navigate to; something of the form #target, which specifies an anchor within the same document that has an attribute name="target"; or a combination, which specifies an anchor within a separate document. For example,
http://www.w3.org/TR/html401/specifies the top of the W3C page for HTML 4.01 and
http://www.w3.org/TR/html401/#minitocspecifies the table of contents further down that web page.
The table element has a summary attribute to describe the table for non-graphical browsers. There are also attributes to control borders, background colours, and widths of columns, but CSS is the preferred way to control these features.
The tr element has attributes for the alignment of the contents of columns, including aligning numeric values on decimal points. There are no corresponding CSS properties.
The td element also has alignment attributes for the contents of a column for one specific row, but these can be handled via CSS instead. However, there are several attributes specific to td elements, in particular, rowspan and colspan which allow a single cell to spread across more than one row or column.
Unless explicit dimensions are given, the table rows and columns are automatically sized to fit their contents.
It is tempting to use tables to arrange content on a web page, but it is recommended to use CSS for this purpose instead. Unfortunately, the support for CSS in web browsers tends to be worse for CSS than it is for table elements, so it may not always be possible to use CSS for arranging content. This warning also applies to controlling borders and background colours via CSS.
An example of a table with three rows and three columns:
<table> <tr> <td></td> <td>pacific</td> <td>eurasian</td> </tr> <tr> <td>min</td> <td>276</td> <td>258</td> </tr> <tr> <td>max</td> <td>283</td> <td>293</td> </tr> </table>
It is also possible to construct more complex tables with separate thead, tbody, and tfoot elements to group rows within the table (i.e., these three elements can go inside a table element, with tr elements inside them).
It is also possible to produce “definition” lists, where each item has a heading. Use a dd element for the overall list with a dt element to give the heading and a dd element to give the definition for each item.
Paul Murrell
This document is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.