3 ms·
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 si
by sirclueless 14y ago
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 { ... }
- alanh 14y agoTwo 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).
- ars 14y ago> 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.