Reputation: 5859
is there a way to stretch the hyplerlink element to the size of a li element inside
<ul>
<li><a href="#">this link to fill up the li element width and height</a><li>
</ul>
Upvotes: 3
Views: 981
Reputation: 57207
Yes. Apply display:block;width:100%
to the element's CSS.
Example:
HTML
<ul>
<li><a href='#'>Link 1</a></li>
<li><a href='#'>Link 2</a></li>
<li><a href='#'>Link 3</a></li>
</ul>
CSS (using selectors - a little trickier but fun)
ul>li>a {
display:block;
width:100%;
}
The <a>
tag is an inline
element, which means that its width can't be styled (and also several other properties). So, the display needs to be changed to block
.
Upvotes: 3