So, I want to make just the first element of a nav-bar to change it's background colour when I hover over it, but both the "Home" and "News" button change colour even though i wrote a:first-child:hover. Please help.
<!DOCTYPE html>
<html>
<head>
<style>
html, nav, ul, li, a, span{
font-family: regular;
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
vertical-align: baseline;
}
.nav, header{
display: block;
}
ol, ul{
list-style: none;
}
a{
text-decoration: none;
}
#header h1 {
left: 1.25em;
margin: 0;
position: absolute;
}
#header {
background: rgba(39, 40, 51, 0.965);
box-shadow: 0 0 0.25em 0 rgba(0, 0, 0, 0.25);
width: 100%;
height: 3.5em;
left: 0;
top: 0;
line-height: 3.5em;
position: fixed;
z-index: 100;
}
#header a, #header a:visited{
color: rgba(224, 224, 224, 0.986);
-o-transition: 0.5s;
-ms-transition: 0.5s;
-moz-transition: 0.5s;
-webkit-transition: 0.5s;
transition: 0.5s;
font-size: 125%;
}
#header nav{
position: absolute;
right: 1em;
top: 0;
}
#header nav ul li{
display: inline-block;
margin-left: 1em;
}
#header nav ul li a:first-child:hover{
background-color: red;
}
</style>
</head>
<body>
<header id="header">
<h1 id="logo"><a href="#">Random</a></h1>
<nav id="nav">
<ul>
<li><a href="">Home</a></li>
<li><a href="#2">News</a></li>
</ul>
</nav>
</header>
</body>
</html>