Formatting Tables

Tables consist of rows and columns. Because the browser ignores white space, which includes tabs, you usually use tables in HTML to display any items that you must separate with white space. Note that this does not necessarily apply to version 4 and higher browsers—you can use absolute positioning to force items to appear at specific pixel locations. Nevertheless, even with modern browsers, tables are useful for more than displaying columnar data.

The <table> tag contains several other tags that serve to delimit the columns and rows. Tables may have three sections—a header, a body, and a footer. The header and footer rows are "fixed" rows— they're not supposed to scroll (although they do in most browsers). The header and footer are optional; you don't have to include them to have a valid table. If you do include either a header or a footer, then you also need to include the body section. Tables may also have a <caption> tag. The browser formats the caption above the first row. Border settings for the table don't apply to the caption.

In addition, tables in IE can contain <colgroup> and <col> tags that can help simplify table formatting. The <colgroup> tag defines a set of columns, and the <col> tag defines an individual column within the column group.

Was this article helpful?

0 0

Post a comment