Making an image clickable is a common requirement in web development. You may want users to click an image to navigate to another page, open an external link, or download a file. HTML provides a simple and clean solution without JavaScript.

Basic Method: Wrap Image Inside an Anchor Tag

The recommended way to make an image clickable is to wrap the <img> tag inside an <a> tag.

<a href="https://wpdevelopertips.in">
  <img src="image.jpg" alt="WPDeveloperTips">
</a>

Open Clickable Image in a New Tab

To open the linked image in a new tab, use target="_blank" with security attributes.

<a href="https://wpdevelopertips.in" target="_blank" rel="noopener noreferrer">
  <img src="image.jpg" alt="Visit WPDeveloperTips">
</a>

Make an Image Clickable for File Download

You can also use images as download buttons using the download attribute.

<a href="brochure.pdf" download>
  <img src="download.png" alt="Download Brochure">
</a>

Clickable Image with Pointer Cursor

Adding a pointer cursor improves user experience.

<a href="/contact">
  <img src="contact.png" alt="Contact Us" style="cursor: pointer;">
</a>

Accessibility Best Practices

Always include descriptive alt text that explains the action performed by clicking the image.

<a href="/pricing">
  <img src="pricing.png" alt="View Pricing Plans">
</a>

SEO Tip

  • Search engines treat clickable images as links
  • The alt attribute works like anchor text
  • Use meaningful keywords in alt text

Common Mistakes to Avoid

Using JavaScript for Navigation

<img src="image.jpg"
     onclick="window.location='page.html'">

This approach is not recommended due to accessibility and SEO issues.

Missing Alt Attribute

<a href="page.html">
  <img src="image.jpg">
</a>

Responsive Clickable Images

Ensure images are responsive on mobile devices.

<a href="page.html">
  <img src="image.jpg"
       alt="Sample Image"
       style="max-width:100%; height:auto;">
</a>
Facebook
WhatsApp
Twitter
LinkedIn
Pinterest

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Articles from the Series

fix-500-internal-server-error-wordpress-thumbnail
How to Fix 500 Internal Server Error in WordPress
What Is a 500 Internal Server Error in WordPress? The 500 Internal Server Error is one of the most common...
fix-there-has-been-a-critical-error-on-this-website-thumbnail
How to Fix “There Has Been a Critical Error on This Website” in WordPress
Seeing the message “There has been a critical error on this website” can be alarming—especially when...
wordpress-harmful-software-warning-fix-thumbnail
Website Showing “Harmful Software” Warning Even After Fresh WordPress Installation – Causes & Fixes
Many WordPress developers assume that deleting all files and installing a fresh copy of WordPress will...
website-with-harmful-software-warning-thumbnail
Website Showing “Harmful Software” Warning When Loading – What It Means & How to Fix It Fast
Seeing a “Website with Harmful Software” or “This site is unsafe” warning when loading a website can...
php-tips-clean-secure-code-thumbnail
PHP Tips to Write Clean and Secure Code
PHP powers a huge portion of the web, including WordPress and many popular CMS platforms. While PHP is...
javascript-tips-cleaner-code-thumbnail
JavaScript Tips to Write Cleaner Code
JavaScript is the backbone of modern web development. From simple interactions to complex web applications,...
css-tips-cleaner-faster-styles-thumbnail
15 CSS Tips to Write Cleaner and Faster Styles
Writing CSS is easy—but writing clean, maintainable, and fast CSS is a real skill. As websites grow,...
add-tooltip-in-html-without-javascript-thumbnail
How to Add a Tooltip in HTML Without JavaScript
Tooltips are small text popups that appear when users hover over an element. They help display additional...
open-link-in-new-tab-html-thumbnail
How to Open a Link in a New Tab Using HTML
Opening links in a new browser tab is a common requirement in web development, especially for external...
replace-enter-title-here-text-for-custom-post-types-thumbnail
Replace Enter Title Here Text for Custom Post Types
Use the below code snippet to change the default ‘Enter the Title Here’ placeholder on the add new post...
Scroll to Top