Super Easy Short Computer Notes To Improve Computer Literacy and Your IT Skills

Sponsored Links

Friday, January 20, 2012

Difference between Cellspacing and Cellpadding

Leave a Comment


Cellspacing and Cellpadding are two important attributes of  <Table> tag. As you know <Table> tag is used to create and display tables in HTML documents.

What is CELLSPACING?

Cellspacing is an important attribute of <Table> tag in HTML. Cellspacing specifies the spacing between adjacent cells in a table. Consider the following example of an HTML table with cellspacing attribute set to 50.

Example of Cellspacing use

<TABLE border="1" cellspacing="30">
<th>Name</th><th>Marks</th>
<tr><td>Sajid Mahmood</td><td>666</td>
<tr><td>Majid Karim</td><td>555</td>
</table>

NameMarks
Sajid Mahmood666
Majid Karim555

Example of Cellspacing=15

<TABLE border="1" cellspacing="15">
<th>Name</th><th>Marks</th>
<tr><td>Sajid Mahmood</td><td>666</td>
<tr><td>Majid Karim</td><td>555</td>
</table>

NameMarks
Sajid Mahmood666
Majid Karim555

Example of Cellspacing=0

<TABLE border="1" cellspacing="0">
<th>Name</th><th>Marks</th>
<tr><td>Sajid Mahmood</td><td>666</td>
<tr><td>Majid Karim</td><td>555</td>
</table>

NameMarks
Sajid Mahmood666
Majid Karim555

What is CellPadding?

Cellpadding is used to specify the distance between a cell contents and its boundaries. For example, consider the following table with cellpadding=0

Example of Cellpadding=0

<TABLE border="1" cellpadding="0">
<th>Name</th><th>Marks</th>
<tr><td>Sajid Mahmood</td><td>666</td>
<tr><td>Majid Karim</td><td>555</td>
</table>

NameMarks
Sajid Mahmood666
Majid Karim555

Example of Cellpadding=20

<TABLE border="1" cellpadding="20">
<th>Name</th><th>Marks</th>
<tr><td>Sajid Mahmood</td><td>666</td>
<tr><td>Majid Karim</td><td>555</td>
</table>

NameMarks
Sajid Mahmood666
Majid Karim555

Example of Cellpadding=50

<TABLE border="1" cellpadding="50">
<th>Name</th><th>Marks</th>
<tr><td>Sajid Mahmood</td><td>666</td>
<tr><td>Majid Karim</td><td>555</td>
</table>

NameMarks
Sajid Mahmood666
Majid Karim555

0 comments:

Sponsored Links

Featured Post

Remove USB Virus Easily by Free Software SMADAV 2018 USB Antivirus

Download Smadav 2018 Free USB Antivirus and Clean your USB easily from viruses: Smadav 2018 : The Best Free Anti Virus For cleaning USB...

.