![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set cell padding in HTML?
We use the inline style attribute, to set cell padding in HTML. Cell padding is the space between cell borders of the table and the content within a cell of the table. The style attribute is used inside the HTML <table> tag, with the CSS property called padding with a specified value in pixels.
Syntax
Following is the syntax to set cell padding in HTML.
<th style="padding: 40px">table header </th>
Example
Following is an example program to set cell padding in HTML.
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style> </head> <body> <h1>Programming Language</h1> <table> <tr> <th style="padding:10px">Language</th> </tr> <tr> <td style="padding:10px">Ruby</td> </tr> </table> </body> </html>
Example
Following is another example program to set cell padding in HTML.
<!DOCTYPE html> <html> <style> table,tr,th,td { border:1px solid black; } </style> <body> <h2>Tables in HTML</h2> <table style="width: 100%"> <tr> <th style="padding: 40px">Name </th> <th>Job role</th> </tr> <tr> <td>Tharun</td> <td style="padding: 10px">Content writer</td> </tr> <tr> <td>Akshaj</td> <td style="padding: 10px">Content writer</td> </tr> </table> </body> </html>
Example
Following is one more example program to set cell padding in HTML.
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding-top: 10px; padding-bottom: 20px; padding-left: 30px; padding-right: 40px; } </style> </head> <body> <table style="width:60%"> <tr> <th>Firstname</th> <th>Lastname</th> <th>salary</th> </tr> <tr> <td>John</td> <td>Smith</td> <td>50,000</td> </tr> <tr> <td>Eva</td> <td>Jackson</td> <td>94,000</td> </tr> <tr> <td>Mike</td> <td>Doe</td> <td>80,000</td> </tr> </table> </body> </html>
Advertisements