Add link to image in css stylesheet

I want to add a link to an image in the acss stylesheet to click on the link when I click on the image.

Code for the image itself:

 #logo{
    background-image: url(images/logo.png);
    width: 981px;
    height: 180px;
    margin-left: auto;
    margin-right: auto;

What is the code to add so that it can go to the hyperlink? For example: if I wanted him to go to http://home.com

+5
source share
4 answers

You cannot do this ...

via the css URLthat you put on background-image, just for the image.

Through HTMLyou should add hreffor your hyperlink as follows:

<a href="http://home.com" id="logo">Your logo</a>

text-indent css , , .


EDIT:

, , , . , , :

<a href="http://home.com" id="logo">Your logo name</a>

HTML SEO, !

css:

#logo {
  background-image: url(images/logo.png);
  display: block;
  margin: 0 auto;
  text-indent: -9999px;
  width: 981px;
  height: 180px;
}

, SEO, .

+12

. . JavaScript .

, :

<a href="home.com" id="logo"></a>
+1

I stumbled upon this old list, reflecting on the same issue. My group help on the same issue was to make the heading text into a link. Then I changed the color and removed the text decoration using CSS. Now, to make the entire header image a link, I expanded the attachment of the anchor tag until it came close to the edge of the header image .... This worked from my point of view, and I decided that I would share it.

0
source

You can do something like

<a href="http://home.com"><img src="images/logo.png" alt="" id="logo"></a>

in HTML

0
source

All Articles