Solved

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

Posted on 2011-03-24
3
262 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
ID: 35211984
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
ID: 35212066
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
ID: 35212111
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

770 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