Baically - I am new to HTML/CSS and I want to center this navigation bar:
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
float: left;
}
li a {
display: block;
text-decoration: none;
padding: 15px 15px;
background-color: rgb(4, 210, 129);
font-weight: 800;
font-family: "Monospace", Lucida Console;
color: white;
}
li a:hover {
background-color: rgb(109, 245, 208);
}
li img {
display: block;
text-decoration: none;
background-color: rgb(4, 210, 129);
}
div {}
.current {
background-color: rgb(109, 245, 208);
}
.end {
display: block;
text-decoration: none;
background-color: rgb(4, 210, 129);
padding: 23px;
box-sizing: border-box;
width: 40%
}
<header>
<nav>
<div>
<ul>
<li><img src="IMG/logo.png" class="logo" /></li>
<li><a href="#" class="current">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Store</a></li>
<li><a href="#">Contact</a></li>
<!-- <li class="end"></li> -->
</ul>
</div>
</nav>
</header>
What I would like to know, is why I can't control the nav bar by using the div element, or by assigning a class or id?
The only way I can control it is by using li a, li img etc.
Why is this? and is there a better way to do it? Thanks.