The cellpadding attribute belonged on <table>. It set the space between each cell’s border and its content — padding inside every <th> and <td> in that table.
Do not use it in new pages. MDN marks it obsolete. Apply the CSS padding property to th and td instead. Do not confuse it with cellspacing (space between cells).
Obsolete.
Presentational HTML. Kept for reading legacy tables — not for new markup. Prefer CSS padding on cells.
Still honored in many browsers.
Old pages may still look padded because engines keep compatibility. That is not a reason to write new cellpadding.
Syntax
HTML Syntax
syntax.html
<table cellpadding="length">
Historical form only. length was pixels (integer) or a percentage.
Try It Yourself shows padding inside cells vs border-spacing between them.
How It Works
Padding = room around the text inside a cell (old cellpadding).
Border-spacing = gap between neighboring cells (old cellspacing).
border-collapse: separate is required for border-spacing to show.
Collapse mode hides between-cell gaps — common for modern grids.
Edge Cases & Pitfalls
Most confusion is mixing padding with spacing.
obsolete
Not for new HTML
Validators flag it. Move spacing into CSS when you touch the table.
naming
Not the same as cellspacing
Inside vs between. Wrong attribute = wrong gap. See the comparison example.
scope
Table-only attribute
It applied from <table> to all cells. Per-cell or per-side padding needs CSS.
cascade
CSS padding can override legacy
A stylesheet may replace the look of an old cellpadding. Prefer one clear CSS source of truth.
units
Attribute had limited units
Pixels or percent. CSS unlocks rem, logical properties, and different padding per side.
Compatibility
Browser Support
cellpadding is an obsolete HTML attribute on tables. Many browsers still honor it for compatibility.
✓ Obsolete · Legacy only
cellpadding
Still applied in modern browsers for old pages. Not recommended for new work — use CSS padding on th and td.
0%Recommended for new work
Google ChromeStill applies · legacy
Legacy only
Mozilla FirefoxStill applies · legacy
Legacy only
Apple SafariStill applies · legacy
Legacy only
Microsoft EdgeStill applies · legacy
Legacy only
OperaStill applies · legacy
Legacy only
Internet ExplorerLegacy support
Legacy only
cellpaddingObsolete — use CSS padding
Bottom line: Expect old tables to keep their HTML padding. Write new cell spacing with CSS padding.
Remember
Key Takeaways
Was: padding inside all cells, set on <table>.
Now: obsolete — use CSS padding on th / td.
Not cellspacing: that is the gap between cells.
CSS wins: per-side padding and modern units.
One line: learn cellpadding to read old tables — ship padding on cells instead.
Frequently Asked Questions
On a table element it set the space between a cell’s border and its content — padding inside every th and td in that table.
Yes. MDN marks it obsolete. Apply the CSS padding property to th and td instead.
cellpadding is space inside cells (content to border). cellspacing is space between cells. In CSS those map roughly to padding on cells vs border-spacing on the table.
No. It belonged on the table element and applied to all cells. Per-cell control always belonged in CSS (or style on individual cells).
A length in pixels (integer) or a percentage. Modern CSS padding supports rem, em, and more flexible units.
Many browsers still honor it for compatibility. New pages should use CSS so spacing stays maintainable.