Rajasekar
Rajasekar

Reputation: 18948

How to set hyperlink for a banner logo. Please help

I am trying to set hyperlink to logo which is at the left side of the banner. when i use

<a href="home.php"> <div class="logo"></div></a>

its not working. help me to come out of this problem

Upvotes: 1

Views: 354

Answers (4)

Joey
Joey

Reputation: 354456

You can't nest block elements like <div> in inline elements like <a>. You can put the <a> tag around the logo image, though:

<a href="home.php">
  <img src="logo.png" alt="Logo">
</a>

Upvotes: 3

Pablo Borowicz
Pablo Borowicz

Reputation: 921

You can't do that since <a> is an inline element, while <div> is a block element. You should replace your <div> with an inline element such as <span>, or follow what Dominic Rodger said.

Upvotes: 4

Esteban K&#252;ber
Esteban K&#252;ber

Reputation: 36832

<a href="home.php"><img src='logo.png' /></a>

Upvotes: 1

Dominic Rodger
Dominic Rodger

Reputation: 99751

For these sorts of things I do something like this:

<div class="logo"><a href="home.php" id="logolink"></a></div>

In my CSS:

a#logolink { display: block; width: 500px; height: 100px; }

Adjusting heights and widths to fit your needs.

Upvotes: 4

Related Questions