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 trial


Why fully select the <a> element instead of the classes defined on the <li> element?

If i change the selectors in my css rules to look like the example below, I get the same result for the contact info icons. Is there any reason I should fully select the anchor element as opposed to just using the classes? Going down to the anchor element feels unnecessary. Thanks!! :)

.contact-info li {
  display: block;
  min-height: 20px;
  background-repeat: no-repeat;
  background-size: 20px 20px;
  padding: 0 0 0 30px;
  margin: 0 0 10px;


.phone {
  background-image: url('../img/phone.png');

2 Answers

Richard Ward
Richard Ward
14,665 Points

Hi Patrick

I'm sure there are many reasons to select the anchor itself rather than just the li element but one reason i find it particularly useful is to expand the 'clickable' area of a link by manipulating the anchor's padding. This is particularly helpful when a user is browsing your site on a mobile device - relying on fingers instead of mouse-pointers for accuracy.

To add to Richard's answer, in this particular project, icons are placed in the 30px of left padding. That makes the icons part of the clickable area. I think the difference you'll find is that if you apply the styles to the list items themselves, you won't be able to click on the icons. Only the text.

Ah. This makes total sense. Thanks for the responses Jason and Richard. :)