I am looking to add a link to an image in a CSS style sheet so it will navigate to the link when the image is pressed.
The code for the image itself is:
#logo{
background-image: url(images/logo.png);
width: 981px;
height: 180px;
margin-left: auto;
margin-right: auto;
What is the code to add to allow it to navigate to a hyperlink? For example: If I wanted it to navigate to http://home.com
You can not do that…
via css the
URLyou put on thebackground-imageis just for the image.Via
HTMLyou have to add thehreffor your hyperlink in this way:With
text-indentand some othercssyou can adjust your a element to show just the image and clicking on it you will go to your link.EDIT:
I’m here again to show you and explain why my solution is much better:
This block of
HTMLis SEO friendly because you have some text inside your link!How to style it with css:
Then if you don’t care about SEO good to choose the other answer.