codesw1tch
codesw1tch

Reputation: 720

My hyperlink goes across entire page instead of just the image

I have a logo that I want to link back to my home page. However, when I hyperlink the logo, I notice that the link spans across the entire page (i.e. across the whitespace to the left and right of the logo) instead of just being on the logo image.

My HTML:

<a href="#" id="splash-logo">
    <img src="images/splash-logo.png" width="259" height="51">   
</a>

My CSS:

#splash-logo {
    clear: both;
    width:100%;
    display: inline-block;
    text-align:center;
}

Thank you!

Upvotes: 1

Views: 2959

Answers (2)

Huangism
Huangism

Reputation: 16448

Get rid of the width:100%, since it is 100% width, of course it will span across (horizontal) the page

Upvotes: 3

bobek
bobek

Reputation: 8020

Your link's width is the width of the parent tag. Instead of doing 100%, just specify the width of the block.

Upvotes: 1

Related Questions