Reputation: 298
My problem is: I have a <a>
tag inside an <li>
and the list have css styling to look like a button, but using like this:
<a href="#"><li>page</li></a>
It isn't correct. How shoud i do?
Is there any way that if I click in every place in the <li>
the link will be triggered?
Upvotes: 5
Views: 17136
Reputation: 41
You say you have an <a>
inside a <li>
but in your code snippet its the other way around. Its not valid or semantic html to have an <a>
tag be the parent of a list item li
.
In any case though, you need to have the <a>
be display:block
Upvotes: 4
Reputation: 9615
<a>
elements are by default inline
positioned. You should change the display
property to block
to occupy the entire space of its parent.
ul {
list-style-type: none;
}
li {
background: blue;
width: 100px;
}
li a {
background: orange;
display: block;
}
<ul>
<li><a href="#">page</a>
</li>
</ul>
Upvotes: 3