HTML Table Cellpadding
Cellpadding attribute places spacing around data within each cell.
Syntax:
<table cellpadding="pixels">
Table without cellpadding:
Example: 1
<html>
<body>
<table border="1" >
<tr>
<th colspan="2">Student</th>
</tr>
<tr>
<th>Name</th>
<th>Roll</th>
</tr>
<tr>
<td>Alex</td>
<td>10</td>
</tr>
<tr>
<td>Susie</td>
<td>11</td>
</tr>
</table>
</body>
</html>
<body>
<table border="1" >
<tr>
<th colspan="2">Student</th>
</tr>
<tr>
<th>Name</th>
<th>Roll</th>
</tr>
<tr>
<td>Alex</td>
<td>10</td>
</tr>
<tr>
<td>Susie</td>
<td>11</td>
</tr>
</table>
</body>
</html>
Output
Student | |
---|---|
Name | Roll |
Alex | 10 |
Susie | 11 |
Table with cellpadding:
Example: 2
<html>
<body>
<table border="1" cellpadding="5">
<tr>
<th colspan="2">Student</th>
</tr>
<tr>
<th>Name</th>
<th>Roll</th>
</tr>
<tr>
<td>Alex</td>
<td>10</td>
</tr>
<tr>
<td>Susie</td>
<td>11</td>
</tr>
</table>
</body>
</html>
<body>
<table border="1" cellpadding="5">
<tr>
<th colspan="2">Student</th>
</tr>
<tr>
<th>Name</th>
<th>Roll</th>
</tr>
<tr>
<td>Alex</td>
<td>10</td>
</tr>
<tr>
<td>Susie</td>
<td>11</td>
</tr>
</table>
</body>
</html>
Output
Student | |
---|---|
Name | Roll |
Alex | 10 |
Susie | 11 |