Chapter 12. Tables

In Chapter 11, I introduced positioning. In this chapter, I discuss some odds and ends related to styling (X)HTML <table> elements and the controls that CSS provides for flexibility.

Tables are primarily a method to show the relationship between data, much as a spreadsheet application does. As I explore some acceptable uses of tables in this chapter, I discuss:

  • The optional table elements that can make it easier to style a table and that make the structure more intuitive

  • Controlling placement of the table caption

  • Controlling the layout of the table

  • Controlling the spacing between table cells

Tables can be complex creatures in (X)HTML. If used properly, they allow information to be presented in a neat, organized, and consistent manner. Put simply, data that needs to show relation and logic should be placed into tables. The discussion presented in this chapter also plays heavily into the discussion about styling XML in Chapter 14. The examples presented in Chapter 14 are identical to those presented in this chapter with one very important difference: They're written in XML.

Tables have several optional elements that may be used to further enhance the structure and presentation of a table. This is where I start the discussion.

Optional Table Elements

The <table> element has several optional elements that can be used to enhance the presentation of a table, including captions, columns, headings, and footers. Take a look at a <table> element that makes use of all these optional ...

Get Beginning CSS: Cascading Style Sheets for Web Design, Second 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.