Cellpadding & Cellspacing
Print This Post
No CommentRelated Reading
|
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> <table border=”1″ cellpadding=”10″> </body> |
We should get this output:
|
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> <table border=”1″ cellspacing=”10″> </body> |
We’ll get the below output for this HTML code:
|
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.








Popular Tags