5
Salim
6y

CSS has no parent selectors... and the codebases' element I'm working on has no classes nor an id...
kill me

Comments
  • 3
    Can js solve it?
  • 2
    and you cant add an class to the parent? Why?
  • 6
    Use tag, descendant and nth child selectors 😂
  • 3
    @mt3o and remeber we can use tag attribute too 😂
  • 2
    Had to solve a similar issue with a table once. Is there some algorithmic pattern you can use that would allow nth-child?

    Also, is it possible to put your own wrapper around the offending bit, perhaps?
  • 2
    @devTea @stop @mt3o @buitrung @Kaji Thanks y'all for your suggestions.

    tl;dr: It's a wor*press mess, I used nth-child, can't js.

    Long talk:

    The element I was trying to select was generated by a js script that's encapsulated in an another element generated by a wor*press theme. Aaaand I had control only over the element's children and the page wrapper.

    I ended up by using nth-child like some of you suggested, even though I don't like it since the thing's order might change in the future.

    It would have been a lot simpler if we had parent selectors...
  • 2
    @Salim yeah but I’ve read it’s not possible since css render from top to bottom or something like that
  • 1
    @devTea RIP

    I'll just avoid generated markup, for my sanity's sake
Add Comment