Notice: The devs are no longer actively involved in the forum, so any bug reports regarding the Stylish extension or this website should be sent to them directly at contact@userstyles.org.
Changing your Avatar.
The only way to currently change a forum avatar is through Gravatar.com. The email address used for your Userstyles.org account must be one of the email addresses that is registered to your Gravatar account.

CSS selectors that should exist, but don't

edited February 2007 in Style Development
We have the child selector (#parent > #child) adjacent sibling selector (div + div). Why isn't there also a parent selector (#child < #parent) and previous sibling selector (div - div)? Sometimes the element you want to style has a child with an id you could use, and avoid a long string of "table > tbody > tr > td > table > tbody > tr > td > p" etc.

Comments

  • Yeah, those would definitely be useful for userstyles on sites with horrible HTML code. I've wished for those many times :) My only guess is that it's harder to code (for UA developers), and/or it's just not very common to ever have to use those...I dunno. I think Javascript and XPath have a way of selecting the parent based on a child, but not sure about the previous sibling one. Could come in handy for CSS though, that's for sure.
  • This guy sounds like he knows what he's talking about. Essentially, it'd be hard to implement because the browser wants to do CSS while parsing the document, so that means looking forward only.
  • There have been several situations where I've wished for selectors like those above. Fortunately I'll be able to solve one of them (element before :last-child) with CSS3 and :nth-last-child(1).
Sign In or Register to comment.