DEV Community

Cover image for Make image elements clickable in HTML?
Chetan Rohilla
Chetan Rohilla

Posted on • Updated on • Originally published at w3courses.org

Make image elements clickable in HTML?

Sometimes we needs to make specific parts or pixels of our images clickable. So, we can do this using map and area HTML tags.

HTML MAP TAG

For an example in the above image we want to make clickable the mobile and laptop area.

So, we will use the code given below to make our image parts clickable.

<img src="workplace.jpg" alt="Workplace" usemap="#workmap" width="400" height="379">
<map name="workmap">
  <area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.htm">
  <area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm">
  <area shape="circle" coords="337,300,44" alt="Cup of coffee" href="coffee.htm">
</map>
Enter fullscreen mode Exit fullscreen mode

Uses of HTML Map and Area Tags or Click on Image Pixels in HTML:

  • Map and Area tags is useful in custom image map and we can make clickable map markers.
  • It is also useful in generating click impressions on any image in digital marketing.
  • We can also use these tags in ecommerce products images.
  • We can also have some animations and effects by using these tags.
  • You can make images specific points clickable in html or image pixels clickable in html.
  • You can draw custom shapes like circle, rectangle, polygon or any canvas on any images in html

Please like share subscribe and give positive feedback to motivate me to write more for you.

For more tutorials please visit my website.

Thanks:)
Happy Coding:)

Top comments (0)