Skip to Main Content
Creating a Website: The Missing Manual, 3rd Edition
book

Creating a Website: The Missing Manual, 3rd Edition

by Matthew MacDonald
May 2011
Beginner content levelBeginner
584 pages
17h 42m
English
O'Reilly Media, Inc.
Content preview from Creating a Website: The Missing Manual, 3rd Edition

HTML Elements for Tables

An HTML table is a grid of cells built out of rows and columns. In the Bad Old Days of the Web, crafty web designers used invisible tables to line up pictures and arrange text into columns. Now style sheets fill that gap with top-notch layout features (as described in Chapter 9) and HTML tables are back to being just tables.

A Basic Table

You can whip up a table using these HTML elements:

  • <table> wraps the whole shebang. It’s the starting point for every table.

  • <tr> represents a single table row. Every table element (<table>) contains a series of one or more <tr> elements.

  • <td> represents a table cell (“td” stands for “table data”). For each cell you want in a row, you add one <td> element. You put the text (or numbers, or <img> elements, or pretty much any HTML you like) that you want to appear in that cell inside the <td> element. If you put text in the cell, it displays in the same font as ordinary body text.

  • <th> is an optional table element; you use it when you want to define a column heading. You can use a <th> element instead of a <td> element any time, although it usually makes the most sense in the first row of a table. Browsers format the text inside the <th> element in almost the same way as text in a <td> element, except that they automatically boldface and center the text (unless you apply different formatting rules with a style sheet).

Figure 5-13 shows a table at its simplest.

Here’s a portion of the HTML used to create that table:

<table> <tr> <th>Rank</th> ...
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

Creating a Website: The Missing Manual, 4th Edition

Creating a Website: The Missing Manual, 4th Edition

Matthew MacDonald
Learn to Build a Website

Learn to Build a Website

Cassidy Williams, Camryn Williams

Publisher Resources

ISBN: 9781449306823Supplemental ContentErrata Page