---
title: "HTML – Image Links"
url: https://khanwaseem.com/blog/course/html-image-links
author: "khan Waseem"
published: 2023-09-20
updated: 2023-09-20
topics: ["course", "HTML Tutorial"]
description: "Discover engaging image links in web design. Learn how to create clickable images that enhance user interaction and visual appeal on your website."
---

# HTML – Image Links

In HTML, you can create image links, which are clickable images that lead to other web pages or resources. This is a powerful way to make your website more visually engaging and interactive. Here’s how you can create image links:

- **Basic Image Link:**
To create a basic image link, you can use the `<a>` (anchor) element and wrap an `<img>` (image) element within it. Here’s an example:

```xml
<!DOCTYPE html>
<html>
<head>
    <title>Basic Image example</title>
</head>
<body>
    <a href="https://www.example.com">
        <img src="background.jpg" alt="Description of the image" width="400">
    </a>
</body>
</html>Code language: HTML, XML (xml)
```

**Output : **

![](https://blogkhanwaseem.s3.amazonaws.com/uploads/2023/09/20163802/image-201.png)

In this example, the `<a>` element surrounds the `<img>` element, making the image clickable. When a user clicks on the image, it will take them to the specified URL.

- **Image Link with Hover Effects:**
You can add hover effects to your image links using CSS to provide visual feedback to users when they hover over the image. Here’s an example:

```xml
<!DOCTYPE html>
<html>
<head>
    <title>Image Link with Hover Effects</title>
</head>
<body>
    <style>
        .image-link{
            padding: 10px;
            border: 2px solid transparent;
            transition: border-color 0.3s;
            width: 400px;
        }
        .image-link:hover {
            border-color: #007bff; /* Change border color on hover */
        }
    </style>
    <div class="image-link">
        <a href="https://www.example.com" >
            <img src="background.jpg" alt="Description of the image" width="400">
        </a>
    </div>
</body>
</html>Code language: HTML, XML (xml)
```

**Output : **

![](https://blogkhanwaseem.s3.amazonaws.com/uploads/2023/09/20164510/image-202.png)

In this example, when a user hovers over the image, the border color changes to blue, providing a visual cue that the image is clickable.

- **Image Link with Custom Styling:**
You can customize the styling of image links further by applying CSS styles to them. This allows you to control the appearance, such as size, padding, and background.

```xml
<!DOCTYPE html>
<html>
<head>
    <title>Image Link with Hover Effects</title>
</head>
<body>
    <style>
        .image-link {
            display: block; /* Make the link a block element for better styling */
            text-align: center;
            background-color: #f0f0f0;
            padding: 10px;
        }
        .image-link img {
            max-width: 100%; /* Ensure the image fits within the container */
        }
    </style>
 
    <a href="https://www.example.com" class="image-link">
        <img src="background.jpg" alt="Description of the image" width="400">
    </a>
</body>
</html>Code language: HTML, XML (xml)
```

**Output : **

![](https://blogkhanwaseem.s3.amazonaws.com/uploads/2023/09/20165044/image-203-1024x297.png)

This example styles the image link with a light gray background, centered text, and padding for better visual presentation.

Image links are a valuable addition to web design, as they combine the visual appeal of images with the functionality of hyperlinks. They can be used for a variety of purposes, including navigation, calls to action, and image galleries.

### Related posts:

[CSS – Border](https://blog.khanwaseem.com/css-border/)
[CSS – Links](https://blog.khanwaseem.com/css-links/)
[CSS – Table](https://blog.khanwaseem.com/css-table/)
[CSS – Pseudo Classes](https://blog.khanwaseem.com/css-pseudo-classes/)

Powered by [YARPP](https://yarpp.com).
