The padding property sets the padding of an element.
The padding inside the cells can be specified by applying this property to the TD or TH element.
td, th {
padding: 10px;
}
| Property | Value | Explanation |
|---|---|---|
| padding | length, %, or auto | the top, bottom, left, and right paddings |
padding: 2px; : [all sides] paddings
padding: 2px 4px; : [top, bottom] [left, right] paddings
padding: 2px 4px 6px; : [top] [left, right] [bottom] paddings
padding: 2px 4px 6px 8px; : [top] [right] [bottom] [left] paddings
<html> <head> <title>TAG index</title> <style type="text/css"> table, th, td { border: 2px #2b2b2b solid; } th, td { padding: 30px; } </style> </head> <body> <table> <tr> <th>Heading A</th> <th>Heading B</th> <th>Heading C</th> </tr> <tr> <td>Cell A</td> <td>Cell B</td> <td>Cell C</td> </tr> </table> </body> </html>
| Heading A | Heading B | Heading C |
|---|---|---|
| Cell A | Cell B | Cell C |