Set cellpadding and cellspacing in table using CSS

Erik
Erik
Member
12 Points
1 Posts

In html table we can set cellspacing, cellpadding and border like this

 <table width="100%" cellspacing="0" cellpadding="0" border="0">
    <tr>
     <td></td>
    </tr>
</table>

How we can set through css?

Views: 8648
Total Answered: 3
Total Marked As Answer: 2
Posted On: 27-Dec-2018 07:42

Share:   fb twitter linkedin
Answers
Rashmi
Rashmi
Member
820 Points
17 Posts
         

Use following css class:

.table-css {
    padding: 0 0 0 0;
    margin: 0 0 0 0;
    border: none;
    border-spacing: 0;
}

.table-css tr td {
    padding: 0 0 0 0;
    margin: 0 0 0 0;
    border: none;
}
Posted On: 28-Dec-2018 01:35
Rahul Maurya
Rahul M...
Teacher
4822 Points
23 Posts
         

For "cellpadding", we can simply use padding on table cells using CSS. E.g. for 0px of "cellpadding":

td { padding: 0px;}

For "cellspacing", we can apply the border-spacing using CSS. E.g. for 0px of "cellspacing":

table { 
border-spacing: 0px;
border-collapse: separate;
}
Posted On: 29-Dec-2018 01:38
Olivia
Olivia
Member
10 Points
0 Posts
         
table {  
    border-spacing: 0px;
    border-collapse: collapse;
}
th, td {
    padding: 0;
}
Posted On: 30-Dec-2018 04:13
 Log In to Chat