Tips and Tricks

This section provides a few tricks of the trade for working with tables.

<font> and Tables

Unfortunately, placing <font> tags around a table will not affect the font of all the text contained within the table. You need to repeat the <font> tag and its attributes around the content in every cell of the table. For complex tables with lots of cells, the repetitive <font> tags can actually add significantly to the size of the HTML file (not to mention the visual clutter).

Style sheets are a much more efficient way to apply style information to the contents of a table (and they are the W3C’s method of choice for all your font styling needs).

Waiting for Tables to Display

With current technology and HTML standards, the browser must wait until the entire contents of a table have downloaded before it can begin rendering the page. Any text and graphics outside the table will display quickly while the browser works on the table.

You can use this phenomenon to your advantage by placing outside the table elements you want your viewers to see first (can anybody say “banner ads”?).

Baseline Alignment Trick[5]

If you want to align the first lines of text by their baselines across a row, you should be able to use valign=baseline; in reality, this setting is too unpredictable across browsers to be used reliably. A trick for achieving the same result is to add a nonbreaking space (&nbsp;) in each first line that is set the same size as the largest character. That way, you can ...

Get Web Design in a Nutshell 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.