Skip to main content

Difference between Cellspacing and Cellpadding



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

Comments

Popular posts from this blog

Explain different types of storage devices

Topic: Explain different types of storage devices in Computer systems Storage Devices Storage devices are used to store data and instructions permanently. Storage devices are also called secondary storage devices / backing storage devices / external storage devices or auxiliary storage devices. Examples of storage devices include Hard Disk, CD and DVD etc. Why Secondary Storage Devices are Used? Secondary storage devices are used because: Primary memory(RAM) is volatile and temporary. When computer is switched off, all data in ram is erased. Storage devices can store large amounts of data and instructions permanently whereas Primary memory has less capacity of storing data. Types Of Storage Devices There are three main types of storage devices:  Magnetic Tape   Magnetic Disk   Optical Disk   Flash Memory storage devices 1. Magnetic Tape Magnetic tape is the oldest storage device. It is made of plastic coated with magnetic material. Data is stored on mag

What are uses of computer at Home

Uses of Computer Today, computer is used in almost every field of life. The use of computer has made different tasks very easy for us. Computer can be used at home in the many different ways. Explain different uses of computers at Home Computer has made a very vital impact on our society. People are using computers for performing different tasks quickly and easily. In fact, computer has made our life more comfortable.   Uses of Computer at Home Computer can be used at home in the following ways: 1.  Home Budget Computer can be used to manage the home budget. What are the Uses of computer at home You can easily calculate your expenses and income with the help of a software like Microsoft Excel. In MS Excel you can prepare a simple worksheet to calculate your daily expenses and income. 2. Computer Games An important use of computer at home is playing games. Different types of games are available. And if you have internet connection, then you can play games online

Convert Centimeters to Inches Python Programming | Python Program Conver...

YouTube Video Tutorial How to write a Python program to convert centimetres to inches Formula to convert centimetres to inches   Explanation of this Python Program This Python program prompts the user to enter a height in inches, converts it to centimeters, and then prints the converted value. It uses the conversion factor of 2.54 to perform the conversion and rounds the result to two decimal places before displaying it to the user. Here's an explanation of the provided Python program line by line: python inches = float ( input ( 'Enter the Height in inches to convert into centimeters:' )) This line prompts the user to enter a height in inches and assigns the entered value to the variable inches . The input() function is used to receive input from the user, and float() is used to convert the input into a floating-point number. python centimeters = inches * 2.54 This line calculates the equivalent value in centimeters by multiplying the inches variable by the conver