Making Header Image Clickable Link

By Jeremy Clark
Filed In tips  |  Tagged , , ,  |  5,256 views
TOP       digg

CSSSometimes a text header link just doesn’t cut it. Making a image a clickable header link is very simple. You can see the result above, the area around the name in the image is a link back to the home page.

Here is the basic layout of the code.

<div id="header"><a href="http://www.your-link-to-your-home" id="headerlink"></a></div>

Notice that the actual link doesn’t contain any text so when it’s render by the browser there would be nothing to display and the link wouldn’t show up. That is fixed in the CSS.

#header{
background:url(images/header.jpg) no-repeat bottom left;
height:100px
width:100%;
}
#headerlink{
display:block;
width:100px;
height:100px;
margin:20px 0 0 20px;
}

This will make a 100px X 100px square link that is 20px from the top of the header and 20px from the left. As for most styling it will require some trial and error to get it positioned just right.

Related posts:

  1. CSS Tip: Image Rollover effect
1 Star2 Stars3 Stars4 Stars5 Stars |  (8 votes, average: 4.50 out of 5)
Loading ... Loading ...

14 Comments

  • 12

    Great help. I was able to make my headerimage linkable. That’s one thing that went right for me today in the realm of creating websites. Been trying to add a slideshow, but no luck for two days now. By the way, that reminds me. I want to let everyone know that Steve Jobs passed away today. What a great loss.

    Anyway, thank you.

  • 13

    This is great thank you. Is possible to add a 2nd and 3rd link within the header. I have tried creating a new style and can get the link to work, but positioning it doesn’t seem to work with the margins (i.e will only appear below the 1st header link)

Leave a Reply

Want an Avatar like seen here. Sign up for Gravatar

Subscribe without commenting