html

How to redirect to new page when image is clicked? (html)


I am trying to setup this html code so that when someone clicks on this image they will be redirected to a new url. For some reason when I click the image it redirects the image to google.com and not the page.

https://jsfiddle.net/ssLtf588/

I have the src set to the image which i assume is the error. How should i go about changing this?

    <div class="container">
    <a href="http://google.com">
      <img src="http://i.imgur.com/SSPyEQ3.png" alt="Avatar" class="image">
          <div class="overlay">
              <div class="text">Hello World Whats up!</div>
    </a>
    </div>


Solution

  • Just add target="_blank" if you want it to open in a new window..

    Here you go:

    <a target="_blank" href="http://google.com">