Hi,

I want to build a simple table with icons inside the cells, and I can't seem to get rid of the padding as seen in cell C6. This happens in firefox/chrome/ie (these are the ones I've tested anyway).

I've added to the css the following: img { display: block; }

but to no avail. What can I do?

Thanks.

PS: I should note I have absolutely no prior experience in this area so there might be things that are done completely wrong in my implementation and any advice would be appreciated.

2 answers

1
point
This was chosen as the best answer

My suggestion would be that if you want to keep the cells a constant size, define the size of the cells, not the size of the table. Tables with empty cells seem to auto-adjust when there are other cells with content in them. What worked for me (to get your dimensions, though off by 1 because those dimensions aren't exactly-divisible) is:

td {
    height: 30px;
    width: 29px;
}

Looking at the rest of your code, everything seems pretty standard and correct. Although I've never seen that enormous list at the beginning of your CSS, the browser reset. I usually see a simple asterisk. It's what I use:

* {
    margin:0;
    border:0;
    padding:0;
}

Etc. Hope this is helpful.

Answered over 6 years ago by Ben Saufley
  • Thanks, works great. Dan Kilman over 6 years ago
  • the universal reset is generally accepted to be a PITA as it messes up forms completely, best practice is to set, not reset the styling on the elements you want to level. Use Eric Meyer's reset as a base. http://snook.ca/archives/html_and_css/no_css_reset/ Tony Crockford over 6 years ago
  • I have to agree with tony, erik meyers is a good one i almost always use. Menno Geelen over 6 years ago
  • Good to know, thanks. Although I'm not sure what you mean about it messing up forms? It was unrelated anyway, I probably shouldn't have even mentioned it. Ben Saufley over 6 years ago
0
points

I've found white space under images is sometimes delt with by using:

img {
    vertical-align: bottom;
}

This is in all my main stylesheets and it's worked a treat for a while now.

Answered over 6 years ago by Adrian Lynch