0

I want to make a <h1 class="header"> Some Title </h1> a link with only css, without adding the href="google.com" in the html part.

Anyone knows how to do this?

Seraf
  • 850
  • 1
  • 17
  • 34
  • 2
    You can add the *look* of a link, you can't add the behaviour of one using CSS. – deceze Feb 13 '17 at 14:53
  • 2
    You can't do that with CSS, as far as I know. You could use Javascript and the onclick event though. – Rob Feb 13 '17 at 14:54
  • 3
    The real question is why are you trying to do this? – jmargolisvt Feb 13 '17 at 14:55
  • 1
    What is the goal? What are you trying to achieve? – Dan Feb 13 '17 at 14:56
  • @jmargolisvt Because I only have access to the css part for modifications. I am using nothing else than (mywebsite.com/wp-admin) part of the wordpress thing. – Seraf Feb 13 '17 at 14:57
  • 1
    Assuming you have admin access, you can edit all the files you need from the wp-admin area. Learn to make a child theme and go from there. – jmargolisvt Feb 13 '17 at 15:05
  • Good idea @jmargolisvt I'll leave this question open until css4 comes to the rescue. – Seraf Feb 13 '17 at 15:22

2 Answers2

3

The link adress MUST be in the HTML, you can't put it into CSS. Wrap your <h1> tag with an <a> tag:

<a href="http://www.example.com"><h1 class="header"> Some Title </h1></a>
Johannes
  • 64,305
  • 18
  • 73
  • 130
1

I think there is no way create a link in your html with CSS only. What you can do is to use JavaScript to convert your h1 tags or tag into a link.

PMA
  • 91
  • 2
  • 13