+ 2
Html Link Question
Hi everyone So, I'm doing a website and I want my logo to be at the navigation part of it as link to the index.html page. I put the image as a background on my <li> and I can't make my image link to the page. Do you have any idea that may work? Thanks all
3 Respuestas
+ 1
Don't put it as a background image, I don't exactly understand what you are trying to do but <a><img></a> should work for most things?
+ 3
It sounds like you want to use an anchor element with the tag name "a" in your li.
Something like this:
<nav>
<ul>
<li>
<a class="logo" href="index.html"></a>
</li>
</ul>
</nav>
You could then show your logo with CSS like this in a style or external CSS file:
.logo {
background-image: url('mylogo.png');
display: block; /* "a" elements default to inline which will ignore height and width. block and inline-block will not ignore width and height so they're ok for showing your logo. */
height: 50px;
width: 50px;
background-size: contain; /* Automatically adjust the image size to roughly match aspect ratio of the actual logo */
}
+ 1
Thanks all of you
I'll try both ways and see which one does what I want :-)