0

I need to target some div without any ID or class. Also, I can't do much with nth-child(), because the page changing day-by-day with adding random divs(below and after the needed div). However, the only thing to help here is the inside(of the needed div) tag <ins> with specific and unique class(say uniqueclass). I found this article at css-tricks(https://css-tricks.com/parent-selectors-in-css/) and tried this:

div < .uniqueclass { display: none !important; }

also tried with the :parent, didn't work too.

I need a pure css(including css3) solution. No cross-browser support needed as long as it works with FF :)

update:

the css-tricks link is useless, probably... I missed the fact it was just a suggestion. ...once.

  • No, there is not any *parent selector* in pure `CSS3` for now. – w3debugger Feb 16 '16 at 22:23
  • Yeah, I read this topic before I was posting my question. I'm just desperately want a solution for this... oh – saifriog Feb 16 '16 at 22:25
  • @saifriog what's the exact markup? You might be able to use an attribute selector instead. – Joseph Marikle Feb 16 '16 at 22:28
  • Would be nice to be able to have a parent selector in CSS but we have to settle for using Javascript/jQuery for now. How is this data being populated on the page? Do you have any access to the scripts (likely server-side) to be able to give each parent `
    ` a unique ID or class? Do you work with the people creating the content so they can change them? The unique inner classes are added somewhere in this process, why not have them applied on the parent `
    ` instead?
    – Brett84c Feb 16 '16 at 22:35
  • if you dropped an example of your structure we could tell you if the need of the parent selector is really needed, sometimes the obvious is not ;) silly example: http://codepen.io/anon/pen/qbwOpP 3 div with same content , but only 2 seens where the third hidden, holds a class – G-Cyrillus Feb 16 '16 at 22:48
  • 1
    Joseph Marikle! You have no idea how much I appriciate your answer man! :) I DID THIS with your help, buddy! @Brett84c, I got no access to anything on the server, also I'm limited with the environment(can't use JS or alike), this isn't a project or anything like this. But it's doesn't meter, I solved this with Joseph's help! Thank you folks! THANK A LOT! – saifriog Feb 16 '16 at 22:49
  • This still doesn't target the parent, it just hides the inner class, in this case, the `

    ` element, within the `

    `, by giving it absolute positioning since the outer divs have `overflow:hidden`. The selector `div p.hide-my-parent-or-not` isn't even necessary, he/she can just use `.hide-my-parent-or-not` (and only if the outer divs have the property `display:hidden`). If this works for @saifriog then that's cool, just wanted it to be clear that this CSS is still not targeting the parent. Essentially this is just styling a specific class.
    – Brett84c Feb 16 '16 at 23:14

0 Answers0