Set cellpadding and cellspacing in table using CSS

Erik
Erik
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: 8895
Total Answered: 3
Total Marked As Answer: 2
Posted On: 27-Dec-2018 07:42

Share:   fb twitter linkedin
Answers
Rashmi
Rashmi
1068 Points
19 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...
4916 Points
27 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
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