4 replies [Last post]
whatispunk
Offline
Regular
Last seen: 12 years 28 weeks ago
Timezone: GMT-5
Joined: 2007-06-14
Posts: 13
Points: 0

I am fortunate enough to be writing IE7 specific code, so I have no worries about cross-browser support.

With that said, I cannot seem to get the following rule to work:

table > tr > td {}

I don't understand because tr's are children of tables and td's are children of tr's. So why won't this work?

The following rule DOES work:

table tr > td {}

This is not what I want however, because it will target also

table table tr > td {} and etc.

Any ideas?

whatispunk
Offline
Regular
Last seen: 12 years 28 weeks ago
Timezone: GMT-5
Joined: 2007-06-14
Posts: 13
Points: 0

Solution: I found this 5

Solution:

I found this 5 seconds after I posted my question (I hate when that happens):

table > tbody > tr > td {}

IE7 (and many other browsers) insert the tbody element in between table and tr.
Even though you don't see it that way when you view source, that's what the rendering engine is doing anyways.

thepineapplehead
thepineapplehead's picture
Offline
Guru
Last seen: 31 weeks 2 days ago
Joined: 2004-06-30
Posts: 9668
Points: 801

Seeing the HTML you're using

Seeing the HTML you're using would help. However I'm pretty sure browsers don't just inject more markup into your HTML. That would be a serious security risk.

Verschwindende wrote:
  • CSS doesn't make pies

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 20 hours 17 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9772
Points: 3854

It's a technicality, TPH.

It's a technicality, TPH. The table may only contain zero or one of caption, thead and tfoot, any number of col and colgroup, and must contain one or more of tbody. Oddly enough, tbody opening and closing tags are optional, so even if not explicitly there, tbody is a part of the DOM, and is always the child of table, and parent of one or more of tr.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

thepineapplehead
thepineapplehead's picture
Offline
Guru
Last seen: 31 weeks 2 days ago
Joined: 2004-06-30
Posts: 9668
Points: 801

blimey!

huh, never knew that Wink

Verschwindende wrote:
  • CSS doesn't make pies