I have created a navigation bar with a :hover
effect and I'd like to know how to make that effect persistent, even after the cursor is removed from the area. The effect is a background color under the given word. For example, when Home is selected I'd like for that effect to stay on the element until another element (for example, Register) is clicked.
.navbar {
list-style-type: none;
background-color: black;
display: flex;
justify-content: flex-start;
align-items: center;
margin: 0;
height: 50px;
padding: 0;
}
.navbar a {
text-decoration: none;
color: gray;
padding: 17px;
transition: background-color 0.5s linear;
}
.navbar a:hover {
background-color: green;
color: honeydew;
}
body {
margin: 0;
}
<header>
<nav>
<ul class='navbar'>
<li><a href='#home'>Home</a></li>
<li><a href='#download'>Download</a></li>
<li><a href='#register'>Register</a></li>
<li><a href='#contact'>Contact</a></li>
<li><a href='#FAQ'>FAQ</a></li>
</ul>
</nav>
</header>