Captain Comic
Captain Comic

Reputation: 16196

Clickable logo - Div as link

In the header of my website I have an image. I want this image to become a link. Currently I display the image as a background for a DIV element:

.myheader
{  
  font-weight: bolder;
  text-transform: uppercase; 
  text-align: justify;
  background-image: url(images/back.png);
  background-repeat: no-repeat;
  background-position: top center;
  margin: auto;  
  width: 700px;
  height: 100px; 
}

I want the whole DIV to be clickable as a link to the homepage.

UPDATE Okay, looking at Stack Overflow with FireBug I can see that their logo is not a background but rather an <img> element. Seems that this is the only option.

Upvotes: 0

Views: 1890

Answers (2)

fabrik
fabrik

Reputation: 14365

a.in-question {
    display:block;
    width:100%;
    height:100%;
}

Upvotes: 2

mylesagray
mylesagray

Reputation: 8869

divs cannot be made into links, they are structural elements,

The only way you could go about this is by creating a hyperlink element a inside the logo div and assigning it a class myClass then in a CSS give the following:

a.myClass {
width:700px;
height:100px;
display:block;
}

This should give the impression that the div is clickable by making the a element the same width and height as the logo div

Upvotes: 3

Related Questions