CSS · CSS Tutorial · Lesson 33
CSS Dropdowns
Hoverable dropdown menus with pure CSS.
Create a dropdown box that appears when the user moves the mouse over an element.
Example
<style>
.dropdown { position: relative; display: inline-block; font-family: Arial; }
.dropbtn { background: #04AA6D; color: white; padding: 12px 16px; border: none; }
.dropdown-content { display: none; position: absolute; background: #f9f9f9; min-width: 160px; box-shadow: 0 8px 16px rgba(0,0,0,.2); z-index: 1; }
.dropdown-content a { color: black; padding: 12px 16px; text-decoration: none; display: block; }
.dropdown-content a:hover { background: #ddd; }
.dropdown:hover .dropdown-content { display: block; }
</style>
<div class="dropdown">
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
<a href="#">Link 1</a><a href="#">Link 2</a><a href="#">Link 3</a>
</div>
</div>
Keep reading “CSS Dropdowns”
Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.