Open In App

HTML <table> cellpadding Attribute

Improve
Improve
Like Article
Like
Save
Share
Report

The HTML <table> cell padding Attribute is used to specify the space between the cell content and cell wall. The cellpadding attribute is set in terms of pixels. By default, the padding is set to 0.

Note: The <table> cellpadding Attribute is not supported by HTML5.

Syntax:

<table cellpadding="pixels">

Attribute Values:

pixels: It holds the space between the cell content and cell wall in terms of pixels.

Example 1: In this example, we will see the implementation of table cell padding with an example.

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML table cellpadding Attribute
    </title>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
 
    <h2>
        HTML table cellpadding Attribute
    </h2>
 
    <table border="1" cellpadding="15">
        <caption>Author Details</caption>
 
        <tr>
            <th>NAME</th>
            <th>AGE</th>
            <th>BRANCH</th>
        </tr>
        <tr>
            <td>BITTU</td>
            <td>22</td>
            <td>CSE</td>
        </tr>
        <tr>
            <td>RAM</td>
            <td>21</td>
            <td>ECE</td>
        </tr>
    </table>
</body>
 
</html>


Output:

Example 2: In this example, we will see the implementation of table cell padding with another example.

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML table cellpadding Attribute
    </title>
</head>
 
<body>
    <h1>Company Employees</h1>
 
    <h2>
        Employee Details
    </h2>
 
    <table border="1" cellpadding="40">
        <caption>Employee Information</caption>
 
        <tr>
            <th>Employee ID</th>
            <th>Name</th>
            <th>Position</th>
        </tr>
        <tr>
            <td>001</td>
            <td>John Doe</td>
            <td>Software Engineer</td>
        </tr>
        <tr>
            <td>002</td>
            <td>Jane Smith</td>
            <td>UX Designer</td>
        </tr>
    </table>
</body>
 
</html>


Output:

Screenshot-2023-12-26-161819

Supported Browsers:

  • Google Chrome 1
  • Edge 12
  • Firefox 1
  • Safari 3
  • Opera 12.1


Last Updated : 29 Dec, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads