Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialModure Rares
Courses Plus Student 9,041 PointsHow can I spread the width of a link to all the <li></li> container ?
I want to add <a> in a <li> to make a navigation menu and I want the link to be accessed even if the user presses somewhere inside the <li> item but not on the link. What CSS code should I use ????
2 Answers
Iain Simmons
Treehouse Moderator 32,305 PointsSince an li
element is a block element by default, you could make the anchor tag a block element too and it would take up the full width (minus any padding on the li
):
li a {
display: block;
}
Michael Hernandez
9,746 PointsTry placing the li element inside of the anchor tags.
Iain Simmons
Treehouse Moderator 32,305 PointsOnly li
tags are allowed as direct children of a ul
or ol
element, for it to be valid HTML. Therefore the anchor/a
tag should go within the li
.
Savannah Lynn
13,662 PointsSavannah Lynn
13,662 PointsHi Modure,
Do you have any padding applied to the inside of your li elements?