Bimjo! Why does my table do this weird stuff that drives me nuts?
Tables can certainly be maddening. Fortunately, they've been around long enough that I feel safe in saying that there probably aren't any new ways for a table to mess you up. I mean, somebody has figured out how to fix what's wrong with yours. It's just a matter of finding the answer to the problem.
- spacing - sothingsaren'tsocrowded
- gotchas - those pesky little things that make you pull out your hair
- graphics in tables - how to make that killer interface work
Spacing in tables is controlled by several factors. If you place your text inside <p> tags, there's a certain spacing that tag carries with it. Within the table structure itself are three factors that control how table contents are spaced:
- table border
- cellpadding
- cellspacing
Taken one at a time then, we'll start with the...
border attribute. It is best to specify a border value in your tables even if you don't want a border. Huh? Here's why- some browsers have a default value of 1 (no units) for table borders. If you leave it out, it can still create gaps in your table. Normally not a problem, but very noticeable when using tables to place graphics as part of a page layout.
Fix: add border="0" to the <table> tag
Cellpadding. Definition- the space between the inner walls of the cell and the cell contents. An example, on the top cellpadding set to zero, on the bottom it's set to 10.
Cellspacing. Definition- the physical space between the cells of a table. Can cause unwanted gaps in your table, or create a lined effect that you may find attractive, something like this:
| cellpadding=0 |
cellspacing=0 |
|
| cellpadding=10 |
cellspacing=10 |
|
In the example above, the orange represents the cellspacing (value 10) added to the lower table. The upper table has cellspacing, and cellpadding set to a zero value.
<< back
Feel the need to communicate with His Grand & Exalted Bimjoness hisself?? Well, here's where ya do it! Don't be shy. If you have something you'd like to see here, just let me know and I'll see what I can do about getting it on here.