O'Reilly logo

HTML, XHTML, and CSS Bible, Fourth Edition by Steven M. Schafer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required