How put url to another page in css

I need to put a link to another page in my h2 element. I don't want use href but I need to do this with css Suppose to have this:

  <h2 class="path">Edizione</h2>

And in my css

   . path {
    url: 'https://www.w3schools.com/css/css_link.asp';
    }

Anyone can help me?

2 answers

  • answered 2017-06-17 19:12 James Douglas

    Sorry, but you can't do this with CSS. Also, I'm pretty sure href is for the <a> tag.

    If you want your <h2> to be a link, either wrap it with an <a> tag, or put the <a> tag inside it, like this:

    <a href="path.html"><h2>link</h2></a>
    <h2><a href="path.html">link</a></h2>

  • answered 2017-06-17 19:12 jeanpier_re

    CSS Doesn't let you do redirects, instead try using JavaScript's built in Window.location method. If you have an even binding for an (onClick) event simply add this code inside of the callback and your page will re-direct to the url provided.

    Window.location = 'https://www.w3schools.com/css/css_link.asp';