Solved

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

Posted on 2011-03-24
3
265 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create animated movies for web page 18 85
Powershell output to email works, but readability is low 5 39
Head to not include on scroll 4 23
Html Newline 7 21
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.
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

829 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