What is Cell Padding in HTML?

Learn via video course
FREE
View all courses
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
Topics Covered

What is Cell Padding in HTML?

The Cell padding in HTML is an attribute for the table element (used for td and th elements). It defines the space between the cell’s edges/walls and its content. Cell padding is an inline attribute used under the table tag that can overwrite the CSS style. The value is set in pixels and is set to 1 by default.

Syntax

<table cellpadding="value" >.....</table>

Attribute

ValueFunctionality
PixelsThe number of pixels is used to measure the space generated between the cell content and the defined cell border.

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Example

Example 1: Table with Cellpadding set as 15 pixels

Output

table-with-cell-padding-as-15-pixel

Example 2: Table with Default Cellpadding (1 pixel)

Output output

Cell Padding vs. Cell Spacing

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Differences

CELL PADDINGCELL SPACING
Cell padding defines the space between the content and border of the cell.Cell spacing defines the space between the edges of 2 adjacent cells.
The default value for cell padding is 1.The default value for cell spacing is 2.
Cell padding is associated with a single cell.Cell spacing is associated with more than one cell.
Cell padding is very effective.Cell spacing is less effective as compared to cell padding.
The attribute used to assign cell padding is ‘cellpadding’.The attribute used to assign cell spacing is ‘cellspacing’.

Similarities

Both the attributes cellspacing and cellpadding are used inside the <table> tag. The value for both attributes is measured in terms of pixels.

cellpadding-and-cellspacing

Compatibility

Cell padding works properly in HTML 4.01 and its derivatives. However, it is not supported by HTML5. As an alternative, we can use the padding property in CSS.

Supported Browsers

Cell padding attribute in the HTML table element is supported by most browsers. For example:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera

To know more about tables and the table attributes in HTML, head over to: Table Attributes in HTML, Tables in HTML.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data

Conclusion

  • cellpadding is an attribute for the table element in HTML.
  • It defines the space between the cell's content and its borders.
  • It is an inline attribute used under the table tag and can overwrite the CSS style.
  • Its value is set in pixels and is set to 1 by default.
  • The syntax for using it is .
  • The value specifies the number of pixels used to measure the space generated between the cell content and the defined cell border.
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more