Use :hover to show dropdowns without JavaScript.
/* Dropdown menu */
nav ul ul {
display: none; /* hidden by default */
position: absolute;
top: 100%; /* place below parent */
left: 0;
background: #eee;
padding: 0;
min-width: 180px;
}
nav ul ul li a {
color: #333;
padding: 0.75rem;
}
nav ul ul li a:hover {
background: #ddd;
}
/* Show dropdown on hover */
nav li:hover > ul {
display: block;
}
----------------------------------------------
<nav>
<ul>
<li><a href="#">Home</a></li>
<li>
<a href="#">Services</a>
<ul>
<li><a href="#">Web Development</a></li>
<li><a href="#">Design</a></li>
<li><a href="#">Consulting</a></li>
</ul>
</li>
</ul>
</nav>
nav ul ul { display: none; }position: absolute;position: relative;
(in this case, the parent <li>).top: 100%; left: 0;top: 100% means “start just below the parent’s bottom edge.”
left: 0 aligns it with the left edge of the parent.background: #eee; min-width: 180px;nav ul ul li a { padding: 0.75rem; }nav ul ul li a:hover { background: #ddd; }nav li:hover > ul { display: block; }