Solved

How do you make a certain area of an image a hyperlink

Posted on 2011-03-24
3
256 Views
Last Modified: 2012-05-11
Hi!

Is there a way to make only the logo portion of the below mentioned header a hyperlink?
http://www.topsecurityinc.com/
Currently, the whole header is a hyperlink.
Here is the code:  
<a href="/"><img src="web/images/top-security-inc-header.jpg" style="width:829px;height:150px;margin-top:10px;border:0px" alt=""></a>
Any specific code modifications would be appreciated.
0
Comment
Question by:TrueBlue
3 Comments
 
LVL 2

Assisted Solution

by:ty2845mvn
ty2845mvn earned 100 total points
Comment Utility
You'll want to use area and map if you are stuck using that image as your header.

<img src="web/images/top-security-inc-header.jpg" style="width:829px;height:150px;margin-top:10px;border:0px" alt="" usemap="#logomap">
<map name="logomap">
  <!-- replace the coordinates and shapes below to match your image -->
  <area shape="rect" coords="0,0,82,126" href="link1.html" alt="Link1" />
  <area shape="circle" coords="90,58,3" href="/" alt="Main Page" />
  <area shape="circle" coords="124,58,8" href="circle.html" alt="Circle" />
</map>

The shapes you can use are "rect", "circle", "poly", and "default".
For the coordinates:
x1,y1,x2,y2: If the shape attribute is set to "rect", it specifies the coordinates of the top-left corner and the bottom-right corner of the rectangle
x,y,radius: If the shape attribute is set to "circle", it specifies the coordinates of the circle center and the radius
x1,y1,x2,y2,..,xn,yn: If the shape attribute is set to "poly", it specifies the coordinates of the edges of the polygon. If the first and last coordinate pairs are not the same, the browser must add the last coordinate pair to close the polygon.

(Last bit lifted from http://www.w3schools.com/tags/att_area_coords.asp)
0
 
LVL 12

Assisted Solution

by:Amick
Amick earned 200 total points
Comment Utility
Use an image map.  You may want to style imgmapdiv to display:none.
<div id="imgmapdiv">
			    	<map name="imgmap">
			    		<area shape="poly" coords="43,80,120,11,202,82" href="http://www.topsecurityinc.com" alt="www.topsecurityinc.com">
			    	</map>
			    </div>
			        <img style="width: 829px; height: 150px; margin-top: 10px; border-top-color: currentColor; border-right-color: currentColor; border-bottom-color: currentColor; border-left-color: currentColor; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none;" alt="Move mouse over image" usemap="#imgmap" src="http://www.topsecurityinc.com/web/images/top-security-inc-header.jpg"/>

Open in new window

0
 
LVL 10

Accepted Solution

by:
jtwcs earned 200 total points
Comment Utility
An image map would work but you could also just make some minor changes to your css and markup to achieve the same result.

HTML changes:

Replace your "topgif" span with this,
<span class="topgif">
	<a href="/" title="Orlando Home & Business Security, Orlando Burglar Alarm Monitoring | Top Security Inc"></a>
</span>

Open in new window


CSS changes:

Replace your .topgif declaration with this,
.topgif a{margin-top:10px;display:block;width:210px;height:150px;}

Open in new window


Replace your .header declaration with this,  
.header{height:170px;width:829px;margin-left:0px;margin-top:0px;padding-top:5px;color:#3A6DEB;background-color:#FFF;letter-spacing:4px;background-image: url(/web/images/top-security-inc-header.jpg);background-repeat: no-repeat;background-position: 0px 25px;}

Open in new window


Hope this helps.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article discusses four methods for overlaying images in a container on a web page
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now