News for hackers. Stuff that matters.
Re:The Tilde is an Amazing CSS Selector by sirclueless on Thursday May 17, 2012 @12:05AM (#3985346)
This post abuses IDs. If you have something with the ID #main, it should be unique anyways or else you have invalid markup. If it's unique, why do you need a sibling selector to find it?

This post could be improved by using classes:

    #container input:checked ~ .main > .findMe { ... }
But really, the sibling selector is powerful enough that you might not need classes at all. I think the following selector makes a much more powerful statement of the kind of thing you can do now that you couldn't before:

    input:checked ~ div span { ... }
Re:The Tilde is an Amazing CSS Selector by alanh on Thursday May 17, 2012 @01:14AM (#3985551)
Two things very wrong with your last suggestion:

1. total lack of semantic value - you cannot possibly get more meaningless than “span inside a div” there. It makes for extremely brittle CSS.

2. You should be using classes rather than elements in your selectors when possible, not only to make the code more maintainable and flexible, but also because it’s more performant (if you care).

Re:The Tilde is an Amazing CSS Selector by ars on Thursday May 17, 2012 @04:55AM (#3986076)
> If it's unique, why do you need a sibling selector to find it?

That selector is not to find it, it's to say #main IS a sibling. If #main exists but is not a sibling then apply different css to it.