Click to See Complete Forum and Search --> : setting cell pad and space for table not working?


etard
12-12-2008, 11:10 AM
All of my styles are defined in an external css sheet. Why would this not work to properly remove cell pad and cells pacing?

.maintd {width: 900px;margin-right: auto;margin-left: auto;border-collapse:collapse;padding:0;}

and then, to my table, apply class="maintd"

It does not remove the cell padding or spacing. I do not want to put cellpadding="0" cellspacing="0" in my actual code, want to control it via the CSS. Since I will have tables that do need cell pad and spacing, I do not want to make an overall style that says no cell pad or cell spacing for all tables. I just want to make different styles for different tables needs, but I cannot seem to remove spacing or padding with this above option - and front what I gather, it should.

what am I missing?

aj_nsc
12-12-2008, 11:17 AM
With regards to cell padding, you need something like this:


table td { padding:0; }


As for cellspacing, check out border-spacing (http://www.w3schools.com/css/pr_tab_border-spacing.asp)

etard
12-12-2008, 11:22 AM
yeah, but if you put that piece in your external css sheet, it would make ALL tables have 0 padding. what if there is a table I put on the page and want it to have 5 and another 3 and another 0. That is why I wanted to control just THIS tables cell padding and spacing in ITS specific style. not a universal style that would control all tables data.

OctoberWind
12-13-2008, 02:32 PM
where is class="maintd" applied to? If it's to the table (as you stated in the OP) then the padding is applied to the table, not the td.

What you can do, if you can't access the HTML is change the css to say .maintd td {} (or better yet table.maintd td {} which would apply the style {} to 'any <td> withing a table with the class of maintd.

etard
12-13-2008, 04:43 PM
where is class="maintd" applied to? If it's to the table (as you stated in the OP) then the padding is applied to the table, not the td.

What you can do, if you can't access the HTML is change the css to say .maintd td {} (or better yet table.maintd td {} which would apply the style {} to 'any <td> withing a table with the class of maintd.

'maintd' is applied to just a single table, an no others, as it specifies some properties of just that table.

ahhh... I see about it being applied to the table as opposed to the desired TD.

what you proposed worked perfect. thanks! I was trying to get just the 1 table property of "maintd" to control all aspects of the table, including the TD, but I see now the error in my assumption. thanks