What does the > do?

liunx

Guest
Hi

I've been noticing recently in people's stylesheets that they are writing things like:

html>#wrapper


What does this do?

Thanks

:: demonseed ::Read the W3C specs, all that kind of stuff is on there, here's the answer to your question:

<!-- m --><a class="postlink" href="http://www.w3.org/TR/CSS2/selector.html#child-selectors">http://www.w3.org/TR/CSS2/selector.html#child-selectors</a><!-- m -->

Edit: I've never felt the need to use this selector though, I give everything a class (and an id when neccessary) and use very specific selectors.The child selector is very usefull for hiding styles from Internet Explorer:

.className {
color: red; /* All versions of IE, PC and MAC will show red text */
}

html>body .className {
color: green;
/* All other browsers released year 2000 and after will display green text. */
.
.
.
</style>
</head>
<body>
<p class="className">This text is red in Internet Explorer, but
green in all other standards compliant browsers.</p>
}

IE does not understand the child selector and thus will ignore style rules that contain it. You have to be carefull sometimes with IE 5.01 /PC. If you place spaces around the ">" as in "html > body", IE 5.01/PC will ignore that part and still see the .className { ... } and apply the styles anyway. It's sure to work the way I have it above.Thank you both.

Very helpful.

:: demonseed ::Happy to help. :)

Originally posted by toicontien
IE does not understand the child selector and thus will ignore style rules that contain it.That's why I don't use it (I don't like using browser specific (or in this case not-browser specific)), I can also usually find other ways alround things, clever trickery with the padding and margins and such.I can also usually find other ways alround things, clever trickery with the padding and margins and such.

I wish I could do that for my current projects. The fact remains, unless you are doing pixel-perfect styled, simple layouts, you're going to run into loads of IE bugs for PC and Mac. :rolleyes:

I used to anti-hack too. Not any more.I get by.
 
Back
Top