Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set table cell padding from CSS?

I am struggling with a cell padding issue in a given HTML table (generated by Drupal).

The table is the following:

enter image description here

I tried the following:

.view-thumbnails-of-tips-and-tricks {
    padding: 10px 10px 10px 10px;  
}

I want to adding padding around cell content as following:

enter image description here

Unfortunately, the padding goes around the table, rather than the cells' content. How can I solve this?

like image 892
Jérôme Verstrynge Avatar asked Dec 16 '22 01:12

Jérôme Verstrynge


2 Answers

.view-thumbnails-of-tips-and-tricks tr td {
    padding: 10px;  
}
like image 65
The Alpha Avatar answered Jan 17 '23 19:01

The Alpha


Specify td after your class:

.view-thumbnails-of-tips-and-tricks td {
    padding: 10px;  
}

Also, make sure to set cellpadding to zero in the HTML in case user-agent stylesheets provide their own value. This value may override or add to the CSS value.

<table cellpadding="0">
like image 36
Evan Mulawski Avatar answered Jan 17 '23 21:01

Evan Mulawski