1. Home
  2. Computing & Technology
  3. Web Design / HTML

Getting Rid of Spaces in HTML Tables

By , About.com Guide

If you're using tables for page layout (a no no in XHTML, by the way), you may have run into the problem of extra spaces in your layouts. In order to fix this you need to check several things:

  1. Does your table have the cellpadding attribute set to 0?
    cellpadding="0"
  2. Does your table have the cellspacing attribute set to 0?
    cellspacing="0"
  3. Are there any spaces before or after your <td>, </td>, <th>, and </th> tags?

Number 3 is the kicker. Many HTML editors like to have the code all spaced out, to make it pretty and easy to read. But many browsers interpret those tabs, spaces, and carriage returns as desired extra space inside your tables. Get rid of the whitespace and you'll have crisper tables.

Explore Web Design / HTML
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Web Design / HTML

©2010 About.com, a part of The New York Times Company.

All rights reserved.