user1908557
user1908557

Reputation: 1

the best way to add an anchor with image and text?

I'm trying to make an HTML anchor that includes an image with a visible text legend on top. My code is:

<li class="grelha lin2 col4">
    <a href="#">
    <img src="img/imagem.gif" alt="Proj">
    <p class="leg normal">Proj</p>
    </a>
</li>

The CSS is:

.leg {
    width: 112px;
    height: 12px;
    position: relative;
    bottom: 23px;
    vertical-align: bottom;
    text-align: center;
    padding: 4px;
    font-size: 12px;
    font-size: 1.2em;
    font-weight: bold;
    user-select: none;
    display: block;
    z-index: 1000;
}

.nav {
    color: #ccc;
}

.normal {
    background-color: rgba(255,255,255,0.5);
    color: black;
}

Visually everything works great, but the link continues to be detected below the li box that is 120x120px. But nothing is there visually.

The question is: how to achieve the same result that function well in SEO, and allow me to have this boxes close to another working with the right link.

Upvotes: 0

Views: 3978

Answers (1)

Yoav Kadosh
Yoav Kadosh

Reputation: 5155

Using <span> makes more sense here, as it is an inline element rather than <p> which is a block element

<li class="grelha lin4 col1"> 
     <a href="#"> 
         <img src="img/imagem.gif" alt="Proj"> 
         <span>Proj</span>
     </a> 
</li>​

and than use css to style it the way you want

Upvotes: 1

Related Questions