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.

HTML How to Make a Website Styling Web Pages and Navigation Polish the Navigation and Footer

Marianna He
Marianna He
844 Points

How can you tell when you'd need to be specific in writing: nav a, nav li, nav ul, nav for a feature?

If I wanted to add the inline-block, how would I know to add it to nav li and not the nav ul for instance?

Michael Caveney
Michael Caveney
50,144 Points

It depends, right? What are you targeting a specific element for?

Marianna He
Marianna He
844 Points

I agree that it depends. But for instance, let's say I wanted to add an inline block to the navigation text elements. How would I know whether to select the nav a or the nav li or nav ul since they all encompass the text elements?

1 Answer

Steven Parker
Steven Parker
221,070 Points

Once you determine what kind of change you want to make, it will generally be clear which element(s) you will want to apply the change to.

I notice in your examples the target elements are very different: link (nav a), list item (nav li), list (nav ul), and section (nav). In many cases, the kind of styling you would apply would be unique to the kind of element you are applying it to. Some properties can only be used on certain elements.

In the case of wanting to add inline-block to the navigation text elements, you would probably select "nav li" since all the text elements would be in the list items (a ul would not have text other than what was inside the li's). But a more important question would be what effect are you trying to achieve with that change, and is it the best way to get the effect you want? That's the question that will lead you to both the specific properties and values AND the elements to apply them to.