How do I CSS Style a Table that affects TD as well?
I want to apply a class to the table, that allows me to style the "td" without having to do something like this:
<table class="myStyle"><tr><td="borderthing"></td><td style="borderthing"></td><td="borderthing"></td></tr></table>
CSS Wise, I can do:
table.myStyle开发者_StackOverflow {
}
Is there a way I can do:
table.myStyle.td {
// borderthing
}
Use the descendant operator (space), or the direct descendant operator (>
).
table.myStyle td { ... }
table.myStyle > tbody > tr > td { ... }
The second one will be applied only to cells in the same table if you have nested tables.
Just remove the dot. Dots are for classes. Spaces are for descendants. >
are for first-generation descendants (i.e. children).
table.myStyle td {
// borderthing
}
Also, what does this line mean:
<td="borderthing"></td>
Did you just forget the class=
attribute? If not, that's completely invalid HTML.
精彩评论