Welcome!

And don't forget to edit your signature & profile.

 

Icon

Statistics

  • Total posts 26807
  • Total topics 4870
  • Total members 6610
  • Our newest member
    manjula12

TOP POSTERS

making a logo clickable

All problems and developments related to (X)HTML-markup and stylesheets are discussed and resolved here.
   

making a logo clickable

Postby castles » Mon Sep 14, 2009 1:29 am

How do I make my logo a clickable link back to the homepage using my css


/* header-photo */
#header-photo {
position: relative;
clear: both;
margin: 5px auto;
display: block;
height: 132px;
width: 850px;
background: #fff url(artistically-speaking-logo.jpg) no-repeat center center;
}
castles
 
Posts: 1
Joined: Mon Sep 14, 2009 1:26 am
   

   

Re: making a logo clickable

Postby Andy » Mon Sep 14, 2009 7:42 am

Example as follows:

Code: Select all
#brand a {
  background: url(logo.png) no-repeat;
  display: block;
  height: 150px;
  overflow: hidden;
  text-indent: -9999em;
  width: 300px;
}


Code: Select all
<div id="brand"><a href="/">Site Name</a></div>
Andy
Smashing <h5>
 
Posts: 1281
Joined: Tue Sep 30, 2008 6:42 pm
Location: Sweden
   

   

Re: making a logo clickable

Postby Tronicscribe » Mon Sep 14, 2009 8:18 pm

Code: Select all
<div id="brand"><a href="/">Site Name</a></div>


Just to keep your code cleaner and minimal, you should just put the id in the a tag

Code: Select all
<a id="brand" href="/">site name</a>


Also, if this logo with the id of brand is only going to appear once per page then this is fine. If you plan on having the same logo with the same id of brand more than once on a page, you should change the id to a class, because you shouldn't have more than one id with the same name on each page. Good practice :)
Tronicscribe
Smashing <frame>
 
Posts: 17
Joined: Sun Mar 29, 2009 12:31 am
   

   

Re: making a logo clickable

Postby mike360 » Wed Sep 16, 2009 5:12 pm

I have stopped using the negative text-indent trick as a means of displaying a logo (or any link with a background image and text, for that matter). Google does not look too kindly upon this method as it can be used to manipulate your search engine ranking.

From Google Webmaster Tools - Hidden Text and Links:

Hiding text or links in your content can cause your site to be perceived as untrustworthy since it presents information to search engines differently than to visitors. Text (such as excessive keywords) can be hidden in several ways, including:

Using white text on a white background
Including text behind an image
Using CSS to hide text
Setting the font size to 0



Your logo is an image, so semantically speaking, you're better off to just use an <img> tag and accompanying ALT text.

Code: Select all
<a href="/"><img src="path/to/mylogo.png" alt="My Company Name" /></a>


Hope this helps.
User avatar
mike360
Smashing <frame>
 
Posts: 15
Joined: Mon Feb 09, 2009 5:16 pm
   

   

Re: making a logo clickable

Postby smart.1 » Thu Sep 17, 2009 7:01 am

mike360 wrote:Your logo is an image, so semantically speaking, you're better off to just use an <img> tag and accompanying ALT text.

Code: Select all
<a href="/"><img src="path/to/mylogo.png" alt="My Company Name" /></a>


Hope this helps.

I prefer this solution too, seems clearer.
User avatar
smart.1
Smashing <div>
 
Posts: 116
Joined: Wed Feb 04, 2009 8:46 am
Location: Bucharest, Romania
   


Return to CSS and (X)HTML



Who is online

Users browsing this forum: No registered users and 2 guests