Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I make a tag with an overall div selectable (parent div)

I have a some listing with some child a tag. But the a tag only working the particular element. I want to make overall div will selectable. Here is the sample code

So I want to make the below a tag with select all parents using css. I can’t change the HTML structure

<div class="parent-1">
   <div class="parent-2">
      <a href="https://www.google.com/">element</a>
   </div>
</div>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If I understand your question. You can use the before method on CSS. Please check the below CSS. So it will cover the parent div

.parent-2 > a:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}

.parent-1 {
    position: relative;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading