I have a nav element that has an ID named "menu" and inside it, there are 6 "a" elements. I am trying to select two of them using their IDs. But it's not working.
But if I select the nav element using a class and edit the CSS selectors accordingly, the style works perfectly. So, why it's not working with an ID but working fine with a class?
#menu {
display: flex;
justify-content: flex-end;
align-items: center;
padding: 10px;
}
#logo {
margin-right: auto;
}
#menu a {
padding: 0 5px;
margin: 0 10px;
}
#hamburger {
display: none;
cursor: pointer;
padding: 5px;
}
.menubar {
width: 30px;
height: 5px;
background-color: black;
margin: 5px 0;
}
a {
text-decoration: none;
color: black;
}
@media screen and (max-width:992px) {
#hamburger {
display: block
}
#menu a:not([id=logo]) {
display: none
}
}
<nav id="menu">
<a id="logo" href="#"><img src="images/Logo.png" alt="logo"></a>
<a href="#">Home</a>
<a href="#">Products</a>
<a href="#">About Us</a>
<a href="#">Contact Us</a>
<a id="hamburger">
<div class="menubar"></div>
<div class="menubar"></div>
<div class="menubar"></div>
</a>
</nav>