CMS

Content

HTML

Images

Monetizing

Home » HTML

Cellpadding & Cellspacing

Monday, 22 March 2010 · Print This Post Print This Post No Comment

Related Reading

  • No related posts
This entry is part 3 of 6 in the series Tables

This lesson of your free online web design course is going to cover the “cellpadding” and “cellspacing” attributes of HTML tables.

Cellpadding


“Cellpadding” refers to the space between the table borders and the cell contents (i.e. your data). It is defined by the “cellpadding” attribute and can take any value (in pixels) starting from zero. Let’s create a table with cellpadding=”10″ (i.e. 10 pixels between the table borders and the cell contents):

<html>
<head>

</head>
<body>

<table border=”1″ cellpadding=”10″>
<tr>
<td>
This Free Online Web Design Course Is Good!
</td>
<td>
Yeah, Definitely! :)
</td>
</tr>
</table>

</body>
</html>

We should get this output:

This Free Online Web Design Course Is Good! Yeah, Definitely! :)

See how the contents are a bit further away from the borders? That is what cellpadding is used for!

Cellspacing

Now that we are through with “cellpadding” let’s learn what “cellspacing” is… “Cellspacing” refers to the space between two cells. Let’s try this attribute out, as well:

<html>
<head>

</head>
<body>

<table border=”1″ cellspacing=”10″>
<tr>
<td>
Actually This Free Online Web Design Course Is The Best!
</td>
<td>
Yeah, Definitely! :)
</td>
</tr>
</table>

</body>
</html>

We’ll get the below output for this HTML code:

Actually This Free Online Web Design Course Is The Best! Yeah, Definitely! :)

See the difference? Good. Also note that you can use both cellpadding and cellspacing at the same time.

If you enjoyed this lesson, please link to it :)

Anyway, this lesson is over! Let’s head on to the next lesson of your free web design course to learn how to define the width and height attributes of your HTML tables.

Series Navigation«Building Simple TablesDefining Table Width & Height»

Bookmark this Post Subscribe to Blog

Popular Tags

Adsense Background Cascading Style Sheets colors Content font Forms GIF Hex Codes HTML Hyperlinking Images IMeye JavaScript JPEG Keyword Research layout Merging meta PNG SEO Sizing spacer Tables text W3C
Leave a Comment

Threaded commenting powered by Spectacu.la code.