user5639310
user5639310

Reputation:

Want to use cellpadding and cellspacing in table by CSS class in different style file

Currently I am doing it by HTML and want to do same by CSS. I have tried myself but it not working. My working HTML is below.

<table class="product_tabel" cellspacing="2" cellpadding="3">

But I am want to use it by CSS class product_tabel so how can I do this?

 .product_tabel
    {
    cellspacing :2;
    cellpadding:3;
    }

Upvotes: 2

Views: 5803

Answers (3)

Rohit Azad Malik
Rohit Azad Malik

Reputation: 32192

try to this way

used to for cellspacing table{border-collapse: separate; border-spacing: 3px;} and cellpadding td{padding:2px;}

demo

 .product_tabel
    {
        border: solid 1px red;
border-collapse: separate;
border-spacing: 3px;
      border:solid 1px red;
    }

.product_tabel td, .product_tabel th{border:solid 1px green;padding:2px;}
<table class="product_tabel">
<tr><td>Hello</td><td>Hello</td><td>Hello</td><td>Hello</td></tr>
  <tr><td>Hello</td><td>Hello</td><td>Hello</td><td>Hello</td></tr>
  <tr><td>Hello</td><td>Hello</td><td>Hello</td><td>Hello</td></tr>
  <tr><td>Hello</td><td>Hello</td><td>Hello</td><td>Hello</td></tr>
  <tr><td>Hello</td><td>Hello</td><td>Hello</td><td>Hello</td></tr>
  </table>

table { border-spacing: 3px; } /* cellspacing */

th, td { padding: 3px; } /* cellpadding */

CSS Cellpadding


CSS Cellspacing

Upvotes: 3

Jyoti Sharma
Jyoti Sharma

Reputation: 994

You can provide css like:

.product_tabel { 
      border-spacing: 5px;
      border-collapse: separate; 
 } /* cellspacing */

.product_tabel th, .product_tabel td { padding: 5px; } /* cellpadding */

Upvotes: 2

Bhola Nath Mahto
Bhola Nath Mahto

Reputation: 484

use simply padding instead of cellpadding

.product_tabel
{
  padding:3px;
}
td{ padding:5px;}

Upvotes: 0

Related Questions