Skip to Content
Table Layout in CSS
book

Table Layout in CSS

by Eric A. Meyer
June 2016
Beginner to intermediate
44 pages
59m
English
O'Reilly Media, Inc.
Content preview from Table Layout in CSS

Chapter 1. Table Layout in CSS

You may have glanced at that title and wondered, “Table layout? Isn’t that exactly what we’re trying to avoid doing?” Indeed so, but this chapter is not about using tables for layout. Instead, it’s about the ways that tables themselves are laid out by CSS, which is a far more complicated affair than it might first appear.

Tables are unusual, compared to the rest of document layout. Until flexbox and grid came along, tables alone possessed the unique ability to associate element sizes with other elements—for example, all the cells in a row have the same height, no matter how much or how little content each individual cell might contain. The same is true for the widths of cells that share a column. Cells that adjoin can share a border, even if the two cells have very different border styles. As we’ll see, these abilities are purchased at the expense of a great many behaviors and rules—many of them rooted deep in the past—that apply to tables, and only tables.

Table Formatting

Before we can start to worry about how cell borders are drawn and tables sized, we need to delve into the fundamental ways in which tables are assembled, and the ways that elements within a table are related. This is referred to as table formatting, and it is quite distinct from table layout: the layout is possible only after the formatting has been completed.

Visually Arranging a Table

The first thing to understand is how CSS defines the arrangement of tables. While this knowledge ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering JavaScript Single Page Application Development

Mastering JavaScript Single Page Application Development

Philip Klauzinski, John Moore
CSS Grid Layout: 5 Practical Projects

CSS Grid Layout: 5 Practical Projects

Craig Buckler, Ilya Bodrov-Krukowski, Giulio Mainardi, Ahmed Bouchefra, Diego Souza

Publisher Resources

ISBN: 9781491930526Errata Page