Add Hyperlinks to Images
![](/_next/image/?url=https%3A%2F%2Fstatic-staging.d-libro.com%2F01-course-content-images%2F1011-10-HTML-CSS-Introduction%2F010-main-figures%2Fadd-hyperlinks-to-images-id101110040510.webp&w=1920&q=75)
You can add hyperlinks to images instead of text by nesting the <img>
tag under the <a>
tag. Please be sure to carefully specify the following two paths: a hyperlink path and an image file path.
Practice
Objective:
Add a hyperlink with an icon
1. Prepare an image file
- Obtain an image file you want to use on your website
- In this practice, we use a search icon file named search-icon.jpg
- Save the file under the img directory
![img folder img folder](https://static.d-libro.com/01-course-content-images/1011-10-HTML-CSS-Introduction/020-image-insert/img-folder-id101110040510-img01.webp)
2. Add a hyperlink and image file path
Add the following code in chapter4.html.
<br>
<br>
<a href="https://www.google.com/">
<img src="img/search-icon.jpg" alt="search" width = "50px">
</a>
3. Check the result with a browser
Open the chapter4.html file with a browser and check if you can jump to Google.com by clicking the search icon.
![A hyperlink added to an image A hyperlink added to an image](https://static.d-libro.com/01-course-content-images/1011-10-HTML-CSS-Introduction/020-image-insert/a-hyperlink-added-to-an-image-id101110040510-img02.webp)