table cell padding and cell spacing code example

Example 1: Set table cellpadding and cellspacing in CSS

td { 
    padding: 10px;  /* cellpadding */
}

table { 
    border-spacing: 10px;   /* cell spacing */
    border-collapse: separate;
}

Example 2: how to give padding around cell in a table in html

<!DOCTYPE html>
<html>
   <head>
      <style>
         table, th, td {
            border: 1px solid black;
         }
      </style>
   </head>

   <body>
      <h1>Programming Language</h1>
      <table>
         <tr>
            <th style="padding:10px">Language</th>
         </tr>
         <tr>
            <td style="padding:10px">Ruby</td>
         </tr>
      </table>
   </body>
</html>

Tags:

Css Example