The Linux Page

cellpadding="..." and cellspacing="..." not working

Today I was trying to create a table in a post and just could not get the cell padding I wanted. Without the padding the data is all cramped together which did not look the way I wanted (see Alexis Wilke Accounts.)

I knew I had the following entry in my CSS but did not think it was stronger than the table cellpadding and cellspacing specifications because I thought it worked for me before!

* {
  margin: 0;
  padding: 0;
}

I was wrong, that definition applies to the td with a greater constrained. So I had to add another entry. I solved the problem using a td definition like this:

table.user-table td {
  padding: 5px;
}

This is of course defined after the previous definition so it is effective last. The only problem with this is that I need to add the "user-table" class to my table definition:

<table class="user-table">...</table>

and it's "hard coded" in the CSS file instead of each individual page. None the less, it works!