Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Modure Rares
Modure Rares
Courses Plus Student 9,041 Points

How 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 ????

Savannah Lynn
Savannah Lynn
13,662 Points

Hi Modure,

Do you have any padding applied to the inside of your li elements?

2 Answers

Since 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
Michael Hernandez
9,746 Points

Try placing the li element inside of the anchor tags.

Only 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.