---
title: "Creating responsive drop-down in HTML"  
description: "This Article demonstrates how to create simple and responsive drop-downs using basic HTML and CSS."  
author: "Ashutosh Patel"  
published: 2024-06-10  
updated: 2024-06-10  
canonical: https://www.mindstick.com/articles/336055/creating-responsive-drop-down-in-html  
category: "html"  
tags: ["html", "html5", "dropdown", "html drop-down"]  
reading_time: 2 minutes  

---

# Creating responsive drop-down in HTML

### Responsive Drop-Down in HTML

When you create a [responsive](https://www.mindstick.com/forum/12845/how-to-responsive-div-table-struggle-multiple-rows) [dropdown menu](https://www.mindstick.com/blog/708/css3-animated-dropdown-menu) in HTML, it often uses a combination of HTML, CSS, and sometimes [JavaScript](https://www.mindstick.com/forum/12869/how-to-c-sharp-and-javascript-email-validation-regex)

## HTML

Basics nav-bar syntax with drop-down

```html
<div class="navbar">
 <a href="#">Home</a>
 <a href="#">About</a>
 <div class="dropdown">
   <button class="dropbtn">Services</button>
   <div class="dropdown-content">
     <a href="#">Web Design</a>
     <a href="#">Graphic Design</a>
     <a href="#">SEO</a>
   </div>
 </div>
 <a href="#">Contact</a>
</div>
```

## Example-

```html
Here is the complete example of how to apply the CSS properties for creating the responsive drop-down using HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" />
<title>Responsive Dropdown Menu</title>
<style>
  /* Basic styling */
  body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
  }

  /* Navbar styling */
  .navbar {
    background-color: #333;
    overflow: hidden;
    display: flex;
    justify-content: end;
    flex-wrap: wrap;
  }

  /* Navbar links */
  .navbar a {
    float: left;
    display: block;
    color: #f2f2f2;
    text-align: center;
    padding: 14px 20px;
    text-decoration: none;
  }

  /* Dropdown container */
  .dropdown {
    float: left;
    overflow: hidden;
  }

  /* Dropdown button */
  .dropdown .dropbtn {
    font-size: 16px;
    border: none;
    outline: none;
    color: white;
    padding: 14px 20px;
    background-color: inherit;
    margin: 0;
  }

  /* Dropdown content */
  .dropdown-content {
    display: none;
    position: absolute;
    background-color: #333;
    min-width: 160px;
    z-index: 1;
  }

  /* Dropdown links */
  .dropdown-content a {
    float: none;
    color: white;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
  }

  /* Show dropdown content on hover */
  .dropdown:hover .dropdown-content {
    display: block;
  }
</style>
</head>
<body>

<div class="navbar">
  <a href="#">Home</a>
  <a href="#">About</a>
  <div class="dropdown">
    <button class="dropbtn">Services <i class="fa-solid fa-angle-down"></i></button>
    <div class="dropdown-content">
      <a href="#">Web Design</a>
      <a href="#">Graphic Design</a>
      <a href="#">SEO</a>
      <a href="#">Digital Marketing</a>
    </div>
  </div>
  <a href="#">Contact</a>
</div>

</body>
</html>
```

**In the above Example-** \
The navbar class is created using the `<div>` element of a class **navbar**.\
Each [menu item](https://www.mindstick.com/forum/339/highlighting-the-menu-item) is a **hyperlink (<a> tag)** in the navbar.

The dropdown menu is created using the class dropdown [content](https://www.mindstick.com/articles/12369/cms-extension-for-magento-2-advanced-content-manager-2) using a combination of button (`<button>` tag) and nested `<div>`.

**CSS** is used to style the **navbar**, **links**, **[dropdown button](https://www.mindstick.com/forum/157550/how-to-add-a-custom-dropdown-button-in-datatable-header)**, and **dropdown content**.

The footer is hidden by [default](https://www.mindstick.com/interview/2204/what-are-the-new-enhancements-done-in-default-project-template-of-asp-dot-net-mvc-4) (`display: none`) and is displayed by hovering over the dropdown button (`:hover`).

## [Output](https://www.mindstick.com/interview/34427/explain-the-output-in-angular)-

![Creating responsive drop-down in HTML](https://www.mindstick.com/mindstickarticle/cb41c64e-ef04-46c6-a33f-a86129120eaa/images/3e59912a-a6fa-4253-bcff-4e3b417184ff.png)

**Also, Read:** [How to create a scroll bar using CSS](https://www.mindstick.com/articles/336054/how-to-create-a-scroll-bar-using-css)

---

Original Source: https://www.mindstick.com/articles/336055/creating-responsive-drop-down-in-html

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
