How to create a mega menu using HTML and CSS ? Last Updated : 28 Nov, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report HTML is a markup language used to create web pages and CSS is a stylesheet language used to design a document written in a markup language such as HTML. In this article, we are going to know how can we create a mega menu on our web page with the help of only HTML and CSS. Mega menus are a type of expandable menu in which many choices are displayed in a row. We have to create a menu that appears when the user moves the mouse over an element inside a navigation bar. Steps to create a mega menu Create an HTML file: Create a navigation menu and use a button as a menu in the navbar to work as a mega menu as shown below code. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <title>Mega Menu</title> <link rel="stylesheet" href="menu.css"> </head> <body> <!-- Created a div for navigation bar--> <div class="navigationBar"> <!-- Created a button to work as a menu--> <div class="downMenu"> <button class="downBtn"> <a href="#">Mega Menu 1</a> </button> <div class="downMenu-content"> <!-- Added items in mega menu 1--> <div class="megaMenu"> <!-- Column 1--> <div class="menuCol"> <a href="#">Menu 1 Col 1 Item 1</a> <a href="#">Menu 1 Col 1 Item 2</a> <a href="#">Menu 1 Col 1 Item 3</a> <a href="#">Menu 1 Col 1 Item 4</a> <a href="#">Menu 1 Col 1 Item 5</a> </div> <!-- Column 2--> <div class="menuCol"> <a href="#">Menu 1 Col 2 Item 1</a> <a href="#">Menu 1 Col 2 Item 2</a> <a href="#">Menu 1 Col 2 Item 3</a> <a href="#">Menu 1 Col 2 Item 4</a> <a href="#">Menu 1 Col 2 Item 5</a> </div> <!-- Column 3--> <div class="menuCol"> <a href="#">Menu 1 Col 3 Item 1</a> <a href="#">Menu 1 Col 3 Item 2</a> <a href="#">Menu 1 Col 3 Item 3</a> <a href="#">Menu 1 Col 3 Item 4</a> <a href="#">Menu 1 Col 3 Item 5</a> </div> </div> </div> </div> <!-- Created another button to work as a menu--> <div class="downMenu"> <button class="downBtn"> <a href="#">Mega Menu 2</a> </button> <div class="downMenu-content"> <!-- Added items in mega menu 2--> <div class="megaMenu"> <!-- Column 1--> <div class="menuCol"> <a href="#">Menu 2 Col 1 Item 1</a> <a href="#">Menu 2 Col 1 Item 2</a> <a href="#">Menu 2 Col 1 Item 3</a> <a href="#">Menu 2 Col 1 Item 4</a> <a href="#">Menu 2 Col 1 Item 5</a> </div> <!-- Column 2--> <div class="menuCol"> <a href="#">Menu 2 Col 2 Item 1</a> <a href="#">Menu 2 Col 2 Item 2</a> <a href="#">Menu 2 Col 2 Item 3</a> <a href="#">Menu 2 Col 2 Item 4</a> <a href="#">Menu 2 Col 2 Item 5</a> </div> <!-- Column 3--> <div class="menuCol"> <a href="#">Menu 2 Col 3 Item 1</a> <a href="#">Menu 2 Col 3 Item 2</a> <a href="#">Menu 2 Col 3 Item 3</a> <a href="#">Menu 2 Col 3 Item 4</a> <a href="#">Menu 2 Col 3 Item 5</a> </div> </div> </div> </div> </div> </body> </html> Create a CSS file: Design your navigation bar and mega menu through CSS and link that file into your HTML page. The following is the content for the file "menu.css" used in the above HTML file. menu.css /* For navigation menu */ .navigationBar { background-color: rgb(65, 122, 230); overflow: hidden; } /* For texts in navigation bar */ .navigationBar a { font-size: 20px; color: white; } /* The dropdown div */ .downMenu { float: left; overflow: hidden; } /* For downButton to work as menu */ .downMenu .downBtn { padding: 15px 15px; background-color: inherit; } /* For hover effect on button */ .navigationBar a:hover, .downMenu:hover .downBtn { background-color: rgb(65, 61, 61); } /* To hide mega menu */ downMenu-content { position: absolute; display: none; width: 100%; } /* To show mega menu on hover */ .downMenu:hover .downMenu-content { display: block; } /* Create columns in mega menu*/ .menuCol { float: left; width: 30%; padding: 10px; background-color: rgb(197, 189, 189); } /* Style the columns */ .menuCol a { float: none; color: black; padding: 10px; margin-bottom: 20px; display: block; } /* Add hover */ .menuCol a:hover { background-color: rgb(223, 223, 223); } Output: Comment More infoAdvertise with us Next Article How to create a mega menu using HTML and CSS ? I iamabhijha Follow Improve Article Tags : CSS HTML-Questions Similar Reads How to create Vertical Menu using HTML and CSS ? In This article, we will learn how to create vertical menus by using HTML and CSS. Vertical Menu: We can create a vertical menu in the form of buttons and a scrollable menu. Vertical Menu is the buttons arranged in the vertical menu bar/navbar. How to create a vertical menu using buttons: We can cre 2 min read How to create a Menu Icon using CSS ? The Menu Icon is mostly used on smaller screens, there's limited space to display a full navigation menu. A menu icon helps in hiding the navigation items initially and revealing them when the user needs them. In this article, we will see how To Create a Menu Icon using CSS. There are many ways to c 3 min read How to Create Nested Sub Menu using CSS ? CSS Nested Sub-Menus refers to Dropdown Menus that are contained within another dropdown menu. These are commonly used in navigation menus to organize and structure content hierarchically. In this article, we are going to build a nested sub-menu using CSS, it will consist of a nav bar with various l 3 min read How to Create An Amazon Clone in HTML and CSS ? Amazon is an e-commerce website for users to buy items online, the UI is user-friendly and has no complex layout or styling. You can easily replicate the site design using HTML and CSS code. You can use svg or icons from other websites for icons and images for the items on the web page to make it lo 9 min read Sidebar Menu Using HTML and CSS In this sidebar menu in HTML and CSS article, weâll cover how to create a sidebar menu using HTML and CSS. Whether youâre a beginner or an experienced web developer, this guide will provide you with the knowledge and skills to build a Responsive sidebar menu in HTML and CSS that improves usability a 2 min read Like