0
<div>
    <span>
        <a class="theclass">Text here</a>
    </span>
</div>

In this example, I want to target the div from the class "theclass", not the div specifically but the parent of the parent, which is the div. I can't change the structure, just the CSS. Is that even possible?

Shmiel
  • 1,201
  • 10
  • 25
Filou
  • 25
  • 5
  • 2
    There is no parent selector in CSS. You need to use Javascript/jQuery for this kind of functionality. – Johannes Aug 01 '22 at 13:55

1 Answers1

0

You can use :has pseudo-class for this one, but it still works only in Safari. No way to do it using pure CSS in every browser. Would be better to handle it with JavaScript.

Ivan Kharkivskyi
  • 569
  • 1
  • 4
  • 22