Cell Padding
The cell padding is used to define the spaces between the cells and its border. If cell padding property is not apply then it will be set as default value.
Example:
<!DOCTYPE html> <html> <head> <title>cell padding</title> <style> table, th, td { border: 2px solid green; text-align:center; } th, td { padding: 20px; background-color:none; } h1 { color:green; } </style> </head> <body> <center> <h1>GeeksforGeeks</h1> <h2>Cell Padding property</h2> <h3>padding: 20px;</h3> <table style="width:70%"> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> </tr> <tr> <td>Harsh</td> <td>Agarwal</td> <td>15</td> </tr> <tr> <td>Manas</td> <td>Chhabra</td> <td>27</td> </tr> <tr> <td>Ramesh</td> <td>Chandra</td> <td>28</td> </tr> </table> </center> </body> </html> |
chevron_right
filter_none
Output:

Cell Spacing
The cell spacing is used to define the space between the cells.
Example:
<!DOCTYPE html> <html> <head> <title>cell spacing property</title> <style> table, th, td { border: 2px solid green; text-align:center; } h1 { color:green; } </style> </head> <body> <center> <h1>GeeksforGeeks</h1> <h2>Cell Spacing property</h2> <h3>cellspacing = "30px"</h3> <table style="width:70%;"cellspacing="30px"> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> </tr> <tr> <td>Harsh</td> <td>Agarwal</td> <td>15</td> </tr> <tr> <td>Manas</td> <td>Chhabra</td> <td>27</td> </tr> <tr> <td>Manas</td> <td>Chhabra</td> <td>27</td> </tr> <tr> <td>Ramesh</td> <td>Chandra</td> <td>28</td> </tr> </table> </center> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browser supported by cell padding and cell spacing are listed below:
- Apple Safari
- Google Chrome
- Firefox
- Opera
- Internet Explorer
Recommended Posts:
- Difference between Cellpadding and Cellspacing
- HTML | <table> cellpadding Attribute
- HTML | <table> cellspacing Attribute
- Difference between bootstrap.css and bootstrap-theme.css
- How to override the CSS properties of a class using another CSS class ?
- jQuery | Get and Set CSS Classes
- How to Set the Gap Between Text and Underlining using CSS ?
- How to Set Color of Progress Bar using HTML and CSS ?
- How to create a drag and drop feature for reordering the images using HTML CSS and jQueryUI ?
- How to create X and Y axis flip animation using HTML and CSS ?
- Websites and Software that help HTML, CSS And JavaScript Developers
- Set the opacity only to background color not on the text in CSS
- How to set multiple background images using CSS?
- How to set Bullet colors in HTML Lists using only CSS?
- Set the limit of text length to N lines using CSS
- Set the size of background image using CSS ?
- How to set alternate table row color using CSS?
- How to set checkbox size in HTML/CSS?
- How to set CSS style to half of a character ?
- How to set flexbox having unequal width of elements using CSS ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


