How to add link to a background image

I have added a image before a div named route-container through css

.route-container::before {
    content: "";
    display: block;
    background: url('') no-repeat;

which shows the image before the div.
I want to give a link to image through css by clicking the image it takes the user to another tab, is it possible?

No, .route-container or an element that is a sibling of it would need to be a link (and CSS sibling selectors would need to be used in that case). HTML elements can be interactive, elements created in CSS cannot.

Actually there is no chance to add html tag in a file which I am editing, so only way to show the image is that I can add the image before the div using ::before . I have to show the image before the div so I uses ::before to show the image

No link then, you can’t create a link without being able to change the HTML.

Ok, there is no solution to it?

Change the HTML, if you cannot do that, then no: you cannot change how a web page fundamentally works using CSS, you can only change how it looks visually.

1 Like

Ok, thanks for your help… :slightly_smiling_face: