How to turn an Image into a Link in HTML ? - GeeksforGeeks (2024)

Last Updated : 16 Jan, 2024

Improve

Improve

Like Article

Like

Save

Report

In this article, we will see how to turn an HTML image into a webpage link in HTML. The HTML <a> type attribute is used to create a hyperlink to web pages, files, and locations on the same page.

We can make elements like images into links by nesting them within an <a> element. It defines a hyperlink that is used to link from one page to another. If the <a> tag has no href attribute, then it will be only a placeholder for a hyperlink.

Syntax:

<a href=""></a>

Note: The ‘ href ‘ attribute is used to specify the destination address of the link.

Example: This example describes adding the link to the image to redirect to a specific page.

HTML

<!DOCTYPE html>

<html>

<body style="text-align: center;">

<h3>

Click on GeeksforGeeks logo to

Redirect into geeksforgeeks.org

</h3>

<img src=

alt="Click to visit geeksforgeeks.org">

</a>

</body>

</html>

Output:

How to turn an Image into a Link in HTML ? - GeeksforGeeks (1)

Making the image as a link in HTML

Example : This example describes adding the link to the image to redirect to a specific page.

HTML

<!DOCTYPE html>

<html>

<head>

<title>Styled Image Link Example</title>

<style>

body {

text-align: center;

background-color: #f4f4f4;

}

h3 {

color: #333;

}

a {

text-decoration: none;

}

#logo {

width: 250px;

height: auto;

border-radius: 8px;

box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);

transition: transform 0.3s ease-in-out;

}

2 #logo:hover {

transform: scale(1.2);

}

</style>

</head>

<body>

<h3>

Click on the styled logo

to visit GeeksforGeeks

</h3>

<!-- Image as a Link -->

<a href="https://geeksforgeeks.org" target="_blank"

rel="noopener noreferrer">

<img id="logo" src=

</a>

</body>

</html>

Output:

How to turn an Image into a Link in HTML ? - GeeksforGeeks (2)



Like Article

Suggest improvement

Share your thoughts in the comments

Please Login to comment...

How to turn an Image into a Link in HTML ? - GeeksforGeeks (2024)

FAQs

How to turn an Image into a Link in HTML ? - GeeksforGeeks? ›

We can make elements like images into links by nesting them within an <a> element. It defines a hyperlink that is used to link from one page to another. If the <a> tag has no href attribute, then it will be only a placeholder for a hyperlink.

How to convert image to link in HTML? ›

The <img> and the <a> tags together is the most common way of adding a clickable image link in HTML. In a webpage, after adding an image using the <img> tag, make it clickable by adding a <a> tag along with it.

How do you generate a URL for an image in HTML? ›

Follow the steps below....
  1. insert your image in the HTML. <img src="image.gif" alt="alt text" />
  2. Front of the image add your starting anchor link. <a href="URL"><img src="image.gif" alt="alt text" />
  3. Add a style to remove the border. <a href="URL"><img src="image.gif" alt="alt text" style="border:none;" />
Feb 7, 2017

How do I redirect an image to a link in HTML? ›

How do I use HTML to make an image a link that redirects to a specific URL? Just wrap your image tag insdie a tag, like this: <a href="https://where-you-want-to-redirect"> <img href="your-image-src">

How do I make an image also a link? ›

To use image as a link in HTML, use the <img> tag as well as the <a> tag with the href attribute. The <img> tag is for using an image in a web page and the <a> tag is for adding a link. Under the image tag src attribute, add the URL of the image.

How to make a link in HTML? ›

A basic link is created by wrapping the text or other content inside an <a> element and using the href attribute, also known as a Hypertext Reference, or target, that contains the web address.

How to create a URL link? ›

You can also insert a URL link by using the shortcut keys "Ctrl+K". The window below asks you to enter the hyperlink URL. If you selected something before using Ctrl+K, the URL itself will not appear on the page but what you selected will serve as a link to http://www.microsoft.com.

How do you make an image a button in HTML? ›

To make an image button in HTML, we will use the <img> tag inside the <button> tag. So in this way, the image will behave like a button. In the src attribute of the image tag, we write the address of the image we want to use. That is all that we have to do inside the body tag.

Which concept is used to display a whole image as a link? ›

Explanation: Active Link concept is used to display whole image as a link​. Active link - It is simply the link that redirects towards the another webpage that contains image or any document. The linked document or text or image is called active text or image.

How to use an image in HTML? ›

In order to put a simple image on a web page, we use the <img> element. This is a void element (meaning, it cannot have any child content and cannot have an end tag) that requires two attributes to be useful: src and alt . The src attribute contains a URL pointing to the image you want to embed in the page.

How do I create a link to a JPEG image? ›

Re: Create a clickable link using a . jpg image. @Steve_Burnes Insert the image into the document and then with it selected, go to the Insert tab of the ribbon and click on the Linl dropdown and then on Insert Link and then insert the URL in the control highlighted in the following screen shot and then click on OK.

How to make an image a Google link? ›

Instructions
  1. Select the image (i.e. click on the image)
  2. Use the Insert link button on the image toolbar that appears (looks like a link in a chain)
  3. Enter the link by either: Search for or choose the page from This site to link to. Search for items in Google Drive (see Link to Drive items) ...
  4. Use the Apply button.

How do I add a link to a PNG image? ›

You cannot embed a hyperlink in a PNG or JPEG image. These image formats are only capable of storing image data and do not have the ability to store code. The href attribute specifies the URL of the image. When a user clicks on the link, their browser will navigate to the specified URL.

Top Articles
Latest Posts
Article information

Author: Velia Krajcik

Last Updated:

Views: 6179

Rating: 4.3 / 5 (74 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Velia Krajcik

Birthday: 1996-07-27

Address: 520 Balistreri Mount, South Armand, OR 60528

Phone: +466880739437

Job: Future Retail Associate

Hobby: Polo, Scouting, Worldbuilding, Cosplaying, Photography, Rowing, Nordic skating

Introduction: My name is Velia Krajcik, I am a handsome, clean, lucky, gleaming, magnificent, proud, glorious person who loves writing and wants to share my knowledge and understanding with you.