HTML and CSS Reference
In-Depth Information
For your pages to play by the XHTML rules, you must include the summary attribute for
all your tables (just as you must include alt text for all your images). You'll learn more
about why accessibility features are important in Lesson 19, “Designing for the Real
Rows and Cells
Now that you've been introduced to the <table> element, we'll move on to the rows and
cells. Inside the <table>...</table> element, you define the actual contents of the
table. Tables are specified in HTML row by row, and each row definition contains all the
cells in that row. So, to create a table, you start with the top row and then each cell in
turn, from left to right. Then you define a second row and its cells, and so on. The num-
ber of columns is calculated based on how many cells there are in each row.
Each table row starts with the <tr> tag and ends with the closing </tr> . Your table can
have as many rows and columns as you like, but you should make sure that each row has
the same number of cells so that the columns line up.
The cells within each row are created using one of two elements:
<th>...</th> elements are used for heading cells. Generally, browsers center the
contents of a <th> cell and render any text in the cell in boldface.
<td>...</td> elements are used for data cells. td stands for table data .
You might have heard somewhere that closing tags are not
required for <th> , <td> , and <tr> tags. You might even see HTML
that's written without them. However, XHTML requires that you
include them, and including them makes your code much easier to
follow. Don't leave them out.
In this table example, the heading cells appear in the top row and are defined with the
following code:
<th> Name </th>
<th> Height </th>
<th> Weight </th>
<th> Eye Color </th>
Search WWH ::

Custom Search