I have a simple navbar. There is a header and then a container which contains all the code.
What I'm trying to do is add padding
to the li
item. When I do it, it just adds it to the left and right but not on top. I've been trying to fix it and I've noticed that if I put padding inside header nav
instead of header nav ul li
it works. Also, if I add float :left
to header nav ul li
.
I just want to know why do I have to add float: left
to header nav ul li
to make the padding work?
.container {
width: 80%;
margin: 0 auto;
}
#brand {
float: left;
}
header nav {
float: right;
}
header nav ul li {
display: inline;
}
<header>
<div class="container">
<div id="brand">
<h1>test</h1>
</div>
<nav>
<ul>
<li><a href="#">1</a></li>
<li><a href="#">Home</a></li>
<li><a href="#">Home</a></li>
</ul>
</nav>
</div>
</header>