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

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

Sean Barry
Sean Barry
4,264 Points

Padding the nav list top & bottom.

Played with the top & bottom padding value and didn't notice a difference. Can you explain what the reason was for this?

nav a { font-weight: 800; padding: 15px 10px; }

1 Answer

Rob Crossland
Rob Crossland
9,158 Points

Padding is used to generate space around or inside content. Anchor tags are inline elements so padding will only affect left, right and bottom space. If you want to affect the top add display: block; or display: inline-block. Also add a background colour you will be able to see the affect of padding more clearly

For a navigation I'd recommend using a list if you haven't already and adding padding to the list item like below

<style>
li{
    background-color: black;
    list-style: none;
    display: inline-block;
    padding: 70px 10px;
}
nav a {
    color: white;
    text-decoration: none;
}
</style>

<body>
<nav>
    <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#">About Us</a></li>
    </ul>
</nav>
</body>

Hope this helped