Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Image Map - Wordpress - Not Working

Hello,

I'm desperately trying to map links on an image using the code editor on a Wordpress Website. I'm using the below code with no luck (I've obviously removed my hyperlinks, title and alt text). The image itself loads on the preview page but my links just won't work. Can anyone please help.

<img src="EXAMPLE-IMAGE" usemap="#image-map">

<map name="image-map">
    <area target="" alt="" title="" href="" coords="2044,408" shape="rect">
    <area target="" alt="" title="" href="" coords="1948,913" shape="rect">
    <area target="" alt="" title="" href="" coords="1771,1017" shape="rect">
    <area target="" alt="" title="" href="" coords="1623,738" shape="rect">
    <area target="" alt="" title="" href="" coords="1450,958" shape="rect">
    <area target="" alt="" title="" href="" coords="983,660" shape="rect">
    <area target="" alt="" title="" href="" coords="566,667" shape="rect">
    <area target="" alt="" title="" href="" coords="336,449" shape="rect">
    <area target="" alt="" title="" href="" coords="230,517" shape="rect">
    <area target="" alt="" title="" href="" coords="390,310" shape="rect">
</map>

Link to image I'm trying to map. https://imgur.com/Q4lDndL

1 Answer

Cameron Childres
Cameron Childres
11,817 Points

Hi Joe,

To define a rectangle in an image map I believe you need two pairs of numbers. The first pair specifies where to start the top-left corner of the rectangle and the second pair determines where it ends on the bottom-right. With just a single set of x-y coordinates there's no way the browser will know what size rectangle you're going for. Try something like this:

<map name="image-map">
    <area target="" alt="" title="" href="" coords="2044, 408, 2088, 452" shape="rect">    
</map>