I am making a simple navigation menu and I want my last list item (search box) to the extreme right of navigation bar.
.nav-list li {
float: left;
margin: 10px 15px;
}
.nav-list .search-box {
float: right;
}
<nav>
<ul class="nav-list">
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Features</li>
<li class="search-box">
Search: <input type="text" name="search" id="search">
</li>
</ul>
</nav>
This is working fine. But when I am trying to target last list item with just the search-box
class like
.search-box {
float: right
}
it is not floating to the right. Can anyone please explain why it is not working ?
Edit: It is also working fine if I target the last item via Id. Like
#search-box {
float: right
}