November 17, 200718 yr I'm wondering if there's any way to change the style of all of a table's cells using CSS. When I use class= on the whole table, only the table itself gets those properties - for example, the border shows up on the outside of the table only, and padding only affects the outermost border, not each individual cell. It is also of course possible to apply a style to all <td> elements, but I want to be able to use classes to have different styles of tables, but I don't want to have <td class="table1"> everywhere. So the question is, can I somehow apply a class to the table and have all cells in the table follow a certain style based on that? Maybe there's some sort of pseudo-class that I'm missing. Anyway, if someone can help, I'd appreciate it. Thanks.
November 17, 200718 yr would this do the trick?table.special tr.special td.special { color:#222222; background:#ffffff; text-align:center; font-Family:sans-serif; }
November 17, 200718 yr Author Well, to further simplify that, you could just do .special {whatever}But the problem is, then I'd have to add class="special" to every single element - td, th, etc.
November 17, 200718 yr Do the reverse in this case as it will tailor to your needs:.special {}.special tr {}.special td {}If you wish to combine it all into a single line with all matching attributes....special, .special tr, .special td {}With this you'll need but a single class= in your table tag and that is all.Some much older browsers (NetScape Navigator 4.x for example) however will not like this and will not render the <td>'s through this css unless you treat the tr's indivually in this way. Which would involve tagging the <tr>'s with a class if you wish to render the <td>'s through CSS using '.special TD'.Additionally, if you are making ALL tables/cells/rows the same colour and want to make them all conform to your CSS, you can do a quick and diry way for it without any classing.TABLE, TR, TD {}orBODY TR, BODY TD {} Edited November 17, 200718 yr by Chozo4
November 18, 200718 yr Author OK, I'll try that. That looks like pretty much exactly what I was looking for. I hope it works! Thanks... I'll let you all know how it works. UPDATE:It worked!! Thanks - you've just saved me a lot of work and frustration. Oh, and it doesn't matter for the older browsers - according to the site logs, most of our users are on IE 6 or 7, Firefox 1 or 2, Safari or Opera. All of these browsers seem to render it fine, and for any browsers with issues, it'll still show up, just not quite perfectly. Edited November 18, 200718 yr by Idontwantspam
January 15, 200818 yr <tr><th colspan="4" bgcolor="#87a966"> <b><a href="http://www.hotmail.com/">Hotmail</a></b><th><tr>i wanna get colspan & bgcolor of <th> into a csshowz it possible???thnx Edited January 15, 200818 yr by n0f3a6
January 16, 200818 yr bgcolor is just background-colorthere is no attribute for colspan Edited January 16, 200818 yr by ripken204
Create an account or sign in to comment