Chapter 9. Tables
IN THIS CHAPTER
Parts of an HTML table
Table width and alignment
Cell spacing and padding
Borders and rules
Rows
Cells
Table captions
Row groups — header, body, and footer
Background colors
Spanning columns and rows
Grouping columns
Tables are a powerful HTML tool with many uses. Developed originally to help communicate tabular data (usually scientific or academic-based data), tables are now used for many purposes — from simply holding tabular data to the layout of entire pages. This chapter covers the basics of tables and progresses into more complex uses of this versatile structure of HTML.
Note
With the advent of CSS, there are many that proclaim tables should no longer be used for layout purposes. Instead, CSS should be used to style and position elements for the sake of layout. However, this is not necessarily the case. Despite the existence of CSS, HTML tables still make a perfectly acceptable layout mechanism, whether on a micro level — a simple table of headers and values — or on a macro level — the layout basis for an entire page or document.
Arguments can be made for both technologies and the debate can get very heated (try searching for "HTML table layout versus CSS layout" at www.google.com
). My advice is to use whichever technology makes sense to you, what you are most comfortable with, what presents your documents in the best light, or what appears to be the best tool for the job.
Parts of an HTML Table
An HTML table is made up of the following parts:
Rows
Columns
Get HTML, XHTML, and CSS Bible, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.