Skip to main content

HTML Table Padding & Spacing

HTML tables can adjust the padding inside each cell and the space between cells.


HTML Table - Cell Padding

Cell padding is the space between a cell's edges and its content. By default it is 0. Add padding with the CSS padding property. You can also set each side on its own with padding-top, padding-bottom, padding-left, and padding-right.

All sides

15 pixels of padding on every side of the cells.

Prompt
A bordered table with 15px of padding inside all cells using the CSS padding property on th and td, with a sample company table.
Output: complete HTML page

Each side

Different padding on the top, bottom, left, and right.

Prompt
A bordered table that sets padding individually on each side of the cells: 10px top, 20px bottom, 30px left, 40px right, with a sample table.
Output: complete HTML page

HTML Table - Cell Spacing

Cell spacing is the space between cells. By default it is 2 pixels. Change it with the CSS border-spacing property on the table element.

Example

30 pixels of space between cells.

Prompt
A bordered table with 30px of space between cells using the CSS border-spacing property on the table element, with a sample table.
Output: complete HTML page