+ 2

What is difference between cellpadding and cellspacing attribute of table tag in html ?

29th May 2017, 1:50 PM
GARG
GARG - avatar
5 Respuestas
+ 16
<!DOCTYPE html> <html> <head> <style> td { background:red; } </style> <title>Page Title</title> </head> <body> <table cellpadding=50> <tr> <td>A</td> <td>B</td> </tr> </table> <table cellspacing=50> <tr> <td>C</td> <td>D</td> </tr> </table> </body> </html>
29th May 2017, 1:55 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 3
Cellspacing specifies the amount of space between one cell and other cells while cellpadding specifies the amount of space between the contents of a single cell and the cell border.
29th May 2017, 1:53 PM
Akshay Hegde
Akshay Hegde - avatar
+ 1
Hey Akshay can you please elaborate cellspacing ?
29th May 2017, 1:56 PM
GARG
GARG - avatar
+ 1
cellspacing adds more space outside the border of a cell | cell1-content | <-cellspacing-> | cell2-content | while padding is within a single cell | <-cellpadding-> cell-content <-cellpadding-> |
29th May 2017, 2:01 PM
Akshay Hegde
Akshay Hegde - avatar
- 1
Check the dictionary the meaning of - - Padding and Spacing then you will understand. - and try coding HTML in Playground to check the difference. ^_^
29th May 2017, 2:27 PM
jamilxt
jamilxt - avatar