I am trying to change the background of the list item when the focus is on the anchor tag. It works on hover, How can I change the background during focus?
I want to make the list more accessible so that even when the user focuses on the anchor tag, the respective list item should also highlight
.main-list{
padding: 10px;
margin: 0 10px;
}
.main-list .list-item{
list-style-type: none;
background: #ccc;
padding: 10px;
border-bottom: 1px solid #333;
cursor: pointer;
}
.main-list .list-item:hover, .main-list .list-item:focus{
background: #ddd;
}
<ul class="main-list">
<li class="list-item"><a href="#">dummy text</a></li>
<li class="list-item"><a href="#">dummy text</a></li>
<li class="list-item"><a href="#">dummy text</a></li>
<li class="list-item"><a href="#">dummy text</a></li>
</ul>