Monday, September 27, 2010

How tables work

In this section, we’re going to look at how tables are structured, and some of the table
element’s attributes, which enable you to define the table’s dimensions and borders, along
with the spacing, padding, and alignment of its cells.
Tabular data works via a system of rows and columns, and HTML tables work in the same
way. The table element defines the beginning and end of a table. Within the table element
are table row elements (<tr></tr>), and nested within those are table cell elements
(<td></td>). The actual content is placed inside the td elements. Therefore, a simple table
with two rows containing two cells each is created like this:
<table>
<tr><td>Cell one</td><td>Cell two</td></tr>
<tr><td>Cell three</td><td>Cell four</td></tr>
</table>

**Note :Always ensure that you include all end tags when working with tables. If you began
working with HTML in the mid-1990s, you may have learned that it’s OK to omit the
odd end tag from tables or table cells. However, not only does this result in invalid
XHTML, but some browsers won’t render tables accurately (or at all) when end tags
are omitted. Furthermore, there’s evidence to suggest some search engines can’t
properly spider pages that contain broken tables.

No comments:

Post a Comment