Skip to content

HTML Links

HTML links are created using the HTML anchor element <a/>. The anchor has an attribute with the name of href that is used to hold the URL of the page to go to when the link is clicked. Here is an example:

1
<a href="http://example.com/mypage.html">Link to mypage</a>

You can use the HTML anchor tag to make many elements clickable, not just text. So you can put images and buttons inside the content of the anchor element.

Linking to Images

The anchor tag allows you to got to another web page if you click on a image. Here is the format of using a clickable image:

1
2
3
<a href="https://www.coderdojotc.org/web-ux/intro-to-html/img/earth.jpg">
   <img src="https://www.coderdojotc.org/web-ux/intro-to-html/img/earth.jpg" alt="Photo of earth from space" width="100" height="100"/>
</a>

Try clicking on this image: Photo of earth from space