How to Create Dropdown Link for Menu with HTML and CSS

In this tutorial we will see How to Create Dropdown Link for Menu with HTML and CSS. Simple HTML and CSS is used for this purpose, complete code is given.

HTML Code

Take a look at the HTML code given below.

<!DOCTYPE html>
<html lang="">
<head>
	<meta charset="utf-8">
	<title>How To Create Dropdown Link for Menu</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <ul>
      <li>
       <a href="#">Profile ▾</a>
       <ul class="dropdown">
        <li><a href="#">Messages</a></li>   
        <li><a href="#">Settings</a></li>   
        <li><a href="#">Logout</a></li>   
       </ul>      
      </li>
    </ul>
</body>
</html>

CSS Code

CSS code is given below.

<style>
* {
    padding: 0;
    margin: 0;
    font-family: monospace;
}
ul {
    text-align: center;    
    list-style: none;
    background: #111827;
}
ul li {
    display: inline-block;
    position: relative;
}
ul li a {
    display: block;
    padding: 20px 25px;
    color: #E0E7FC;
    text-decoration: none;
    text-align: center;
    font-size: 20px;
}
ul.dropdown li {
    display: block;
}
ul li a:hover {
    background: #374151;
    color:#E5E7EB;
}
ul.dropdown {
    width: 100%;
    position: absolute;
    z-index: 999;
    display: none;
}
ul li:hover ul.dropdown {
    display: block;
}
</style>           

Video Tutorial

Watch our video tutorial on How to Create Dropdown Link for Menu with HTML and 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