Simple Dropdown Menu with Pure CSS

In this tutorial we will see how to create a Simple Dropdown Menu with Pure CSS. Simple HTML and CSS is used for this purpose and complete code is given.


Take a look at the HTML code given below.

<!DOCTYPE html>
<html lang="">
	<meta charset="utf-8">
	<title>Dropdown Menu using HTML and CSS</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="styles.css">
<details class="dropdown">
    <summary role="button">
      <a class="button">Menu</a>
      <li><a href="#">Home</a></li>
      <li><a href="#">Dashboard</a></li>
      <li><a href="#">Settings</a></li>
      <li><a href="#">Logout</a></li>

CSS Code

CSS code is given below.

body {
      background-color: #444;
      text-align: center;
      font-family: monospace;
a.button {
      display: inline-block;
      padding: 10px 30px; 
      border-radius: 50px;
      box-sizing: border-box;
      border: none;
      background: #22438C;
      color: #ddd;
      font-size: 20px;
      cursor: pointer;
      position: relative;
.dropdown {
      position: absolute;
      padding: 0;
      margin-right: 1em;
      border: none;
.dropdown summary {
      list-style: none;
      list-style-type: none;
.dropdown summary:focus a.button {
      border: 2px solid #ddd;
.dropdown summary:focus {
      outline: none;
.dropdown ul {
      position: absolute;
      margin: 20px 0 0 0;
      padding: 0;
      width: 120px;
      left: 50%;
      margin-left: calc(120px / 2  * -1);
      box-sizing: border-box;
      z-index: 2;
      background: #ddd;
      border-radius: 6px;
      list-style: none;
.dropdown ul li {
      padding: 0;
      margin: 0;
.dropdown ul li a:link, .dropdown ul li a:visited {
      display: inline-block;
      padding: 10px 0.8rem;
      width: 100%;
      box-sizing: border-box;
      color: #000;
      text-decoration: none;
.dropdown ul li a:hover {
      background-color: #22438C;
      color: #ddd;
.dropdown ul::before {
      content: ' ';
      position: absolute;
      width: 0;
      height: 0;
      top: -10px;
      left: 50%;
      margin-left: -10px;
      border-style: solid;
      border-width: 0 10px 10px 10px;
      border-color: transparent transparent #ddd transparent;
.dropdown > summary::before {
      display: none;
.dropdown[open] > summary::before {
        content: ' ';
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        left: 0;
        bottom: 0;
        z-index: 1;

Video Tutorial

Watch our video tutorial on Simple Dropdown Menu with Pure CSS.

Social Media Menu with Popup Tooltip using HTML and CSS Horizontal Navigation Menu with HTML and CSS Responsive Sidebar Menu with CSS and JavaScript Cool CSS Button with Hover Animation Pure CSS Custom Radio Buttons Custom Emoji Radio Buttons with CSS Color Picker Design with HTML CSS and JavaScript Custom Radio Buttons with CSS Engraved HTML Buttons With CSS Neumorphic Buttons Design with CSS Cool Profile Card Design with HTML CSS Neumorphic Search Bar Design with HTML and CSS Simple Login Form with Placeholder Animation Pure CSS Button with Folded Corner Background Color Change Slider with HTML CSS and JavaScript 404 Page Not Found Template Design with HTML and CSS Movies Blog Card Design with HTML and CSS Simple CSS Border Animation with before and after Selector Custom Social Select Dropdown Menu with CSS and JavaScript Facebook Offline and Online Notification with CSS and JS New Year 2022 Text Animation with CSS and JS Change Placeholder Color using CSS Custom Select Tag DropDown with CSS and JavaScript Simple Price Range Slider With HTML CSS and JavaScript Profile Card With Hover Effect using HTML and CSS Circle With Two Colors using CSS Simple FAQ Accordion With HTML CSS and JavaScript