Web Design Course
Cellspacing and Cellpadding
Last week, we learned a number of table attributes, including ALIGN, WIDTH, BORDER, BGCOLOR, and COLSPAN. If you don’t remember what these do, please go back to the week 8 lesson and review these attributes. Otherwise, we are now going to add CELLSPACING and CELLPADDING to our already long list of table attributes.
Let’s look at our Brady Bunch table from last week’s lesson. Remember this?
| Marcia | Carol | Greg |
| Jan | Alice | Peter |
| Cindy | Mike | Bobby |
Now I’m going to add some cellspacing to this, so you can see the results. First a little bit of cellspacing:
| Marcia | Carol | Greg |
| Jan | Alice | Peter |
| Cindy | Mike | Bobby |
Here is the first line of code for this table:
<TABLE BORDER="1" CELLSPACING=”5”>
Here is a lot of cellspacing:
| Marcia | Carol | Greg |
| Jan | Alice | Peter |
| Cindy | Mike | Bobby |
And here is the first line of code:
<TABLE BORDER="1" CELLSPACING=”20”>
Here is the table with some cellpadding added. Once again, here is a little cellpadding:
<TABLE BORDER="1" CELLPADDING=”5”>
| Marcia | Carol | Greg |
| Jan | Alice | Peter |
| Cindy | Mike | Bobby |
And here is a lot:
<TABLE BORDER="1" CELLPADDING=”20”>
| Marcia | Carol | Greg |
| Jan | Alice | Peter |
| Cindy | Mike | Bobby |
And finally, here is what we get with both cellpadding and cellspacing:
<TABLE BORDER="1" CELLSPACING=”20” CELLPADDING=”20”>
| Marcia | Carol | Greg |
| Jan | Alice | Peter |
| Cindy | Mike | Bobby |
Activating Cells For Links
Wouldn't it be great if you could make a table with words and the words in the table were active so you could click on them? You can! Look at this example:
| CBS Home Page | NBC Home Page |
| ABC Home Page | FOX Home Page |
Here is the code:
<TABLE ALIGN=”center” BORDER=”20” CELLSPACING=”20” CELLPADDING=”20”>
<TR>
<TD ALIGN = “center”>
<A HREF="http://www.cbs.com">CBS Home Page</A>
</TD>
<TD ALIGN = “center”>
<A HREF="http://www.nbc.com">NBC Home Page</A>
</TD></TR>
<TR>
<TD ALIGN = “center”>
<A HREF="http://abc.go.com">ABC Home Page</A>
</TD>
<TD ALIGN = “center”>
<A HREF="http://www.fox.com">FOX Home Page</A>
</TD></TR>
</TABLE>
By the way, you’ll notice that the BORDER, CELLSPACING, AND CELLPADDING commands are all set at 20 in the above table to give you an idea of how this would change the appearance of your table.
Images In Cells
Can I put images in each of the cells? Absolutely! In fact, I can show you an example from this page. See the very top of the page, where there are images of two computers? I used a table to create this effect. Of course, I took away the border, but here’s what the table would look like if I had a border of size 1:
![]() |
Web Design CourseWeek 10: Tables (Part 2) |
![]() |
<TABLE WIDTH="100%" BORDER="1">
<TR>
<TD ALIGN="left"><IMG SRC="images/computer.gif"></TD>
<TD ALIGN="center"><FONT FACE="arial, helvetica" SIZE="-1"><B>Individualized Learning Program</B>
</FONT><H2><FONT COLOR="#CC0000"><I>Web Design Course</I></H2></FONT><B>
<FONT FACE="arial, helvetica" COLOR="#0000CC">Week 9: Tables (Part 2)</FONT></B></TD>
<TD ALIGN="right"><IMG SRC="images/computer.gif"></TD>
</TR>
</TABLE>

