Log in

View Full Version : Table not to use its parent CSS - Help



me_myself
09-16-2008, 04:32 PM
I have a html page with a parent CSS. This CSS has styles for table, tr and td. All tables, tr's and td's gets its style from this CSS file. Now i have a (nested) table within the html and i dont want the parent CSS style to apply the style to this table and its contents. How do i apply a new CSS style only for this Table and its TR, TD?

The problem i face now is this table is getting its style from the parent CSS. I tried putting an ID for this table and creating new styles like "#table_id table{}" but it doesnt seem to work. It still uses the parent CSS.

Please Help. Thanks.

SpOrTsDuDe-Reese
09-16-2008, 05:34 PM
Assign the table an ID and then referance all the first tables CSS under the first table, e.g. table#one and then do table#two for the second. Make sure all descendants of the first table have table#one.

me_myself
09-16-2008, 05:37 PM
Can you please post with a small example code (html and css)? Would the CSS look something like this -

table #one td{}
table #two td{}

Thanks

SpOrTsDuDe-Reese
09-16-2008, 05:46 PM
Sure

Say you have this HTML


<table id="one">
<tr>
<td><!--Crap here-->
</td>
</tr>
</table>

And you have a second table


<table id="two">
<tr>
<td><!--HOLY CRAP, MORE STUFF-->
</td>
</tr>
</table

You would need this CSS


table#one td {
/*Styles here*/
}
table#two td {
/*More styles here*/
}


HTH.