skip to Main Content

I have a personal website and I am trying to have an image and upon clicking, redirect to another website. My own website is for instance www.example.com, and I want to (upon clicking image) go to www.website.com. However, it goes to www.example.com/www.website.com and I do not want that. The code looks alright:

 <a href="www.website.com">
   <br><img src="website.png" alt="Avatar" class="webimage">
 </a>

Any ideas?

2

Answers


  1. This should work. You have to use http:// or https:// in front of the link. Otherwise it will redirect you to a local path.

     <a href="http://www.website.com">
       <br><img src="website.png" alt="Avatar" class="webimage">
     </a>
    Login or Signup to reply.
  2. Relative URL paths are any without a protocol, delimited by //. It could begin http://, https://, or even simply // (though the delimiter without a stated protocol can apparently be used as an attack vector and so should be avoided.

    Relative URLs with ./ or no slash are appended to the current directory. Those with ../ go up one to the parent directory. And those with a single slash (/) go to the site root.

    Since you’re already at site root, that is your current directory, so the address is appended there.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search