开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜