The Wayback Machine - https://web.archive.org/web/20240712015811/https://www.geeksforgeeks.org/pure-css-horizontal-menu/
Open In App

Pure CSS Horizontal Menu

Last Updated : 01 Feb, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

We come across horizontal menus on almost every website. Pure CSS helps us implement such menus with ease by using the pure-menu class. Pure-menu class by default creates a vertical menu which we can simply convert into a horizontal one by adding the class pure-menu-horizontal. One of the most common uses of a horizontal menu is in navigation bars (navbars). 

We will use the following classes to help us achieve the goal at hand:

  • pure-menu: This helps us create a menu. (creates a vertical menu by default)
  • pure-menu-horizontal: This helps us create a horizontal menu.
  • pure-menu-list: This helps us specify the list which contains the menu items.
  • pure-menu-item: This helps us specify that a particular item belongs in the list
  • pure-menu-link: This helps us specify the links in the menu items
  • pure-menu-heading: This helps us specify a heading for our menu

Syntax:

<div class="pure-menu pure-menu-horizontal">
    <ul class="pure-menu-list">
        <li class="pure-menu-heading">...</li>
        <li class="pure-menu-item">
            <a href="#" class="pure-menu-link">
                ...
            </a>
        </li>
    </ul>
</div>

Note: Do not forget to add the pure CSS CDN to be able to use the pure CSS framework

Example: Let us suppose we want to create a horizontal menu for the nav bar of our portfolio. 

HTML




<!DOCTYPE html>
<html>
  
<head>
    <!--pure-CSS-CDN-->
    <link rel="stylesheet"
          href=
          integrity=
"sha384-Uu6IeWbM+gzNVXJcM9XV3SohHtmWE+3VGi496jvgX1jyvDTXfdK+rfZc8C1Aehk5" 
          crossorigin=
"anonymous">
  
    <!--Custom style for the logo-->
    <style>
        .logo {
            color: #2f8d46;
            font-weight: bold;
            font-size: 1.5rem;
        }
    </style>
  
    <title>Menu</title>
</head>
  
<body>
    <nav class="menu pure-menu pure-menu-horizontal">
        <a href="#" 
           class="logo pure-menu-heading pure-menu-link">
            MYSITE
        </a>
        <ul class="menu pure-menu-list">
            <li class="pure-menu-item">
                <a class="pure-menu-link">
                  About
                </a>
            </li>
            <li class="pure-menu-item">
                <a class="pure-menu-link">
                  Projects
                </a>
            </li>
            <li class="pure-menu-item">
                <a class="pure-menu-link">
                  Contact
                </a>
            </li>
        </ul>
    </nav>
</body>
  
</html>


Output:

Pure CSS Horizontal Menu

Pure CSS Horizontal Menu



Previous Article
Next Article

Similar Reads

Design a Vertical and Horizontal menu using Pure CSS
Menu is a very important component in any website. It is a user interface element within a webpage that contains links to other sections of the website. It can be displayed horizontally or vertically before the main content of the webpage or header. For Creating Vertical Menu: Menus are vertical by default in Pure CSS. It is easy to customize becau
2 min read
Pure CSS Responsive Horizontal-to-Vertical Menu Layout
To create a responsive horizontal-to-vertical menu layout using only CSS, you can use media queries to apply different styles to the menu based on the width of the viewport. Example 1: This will create a horizontal menu with evenly distributed menu items on larger screens, and a vertical menu with full-width menu items on smaller screens. You can a
3 min read
Pure CSS Responsive Horizontal-to-Scrollable Menu Layout
A Horizontal-to-Scrollable menu is a type of responsive menu bar in Pure.CSS, which changes the horizontal menu bar to a horizontally scrollable menu bar. It is used to make the menu bar responsive when the width of the website increases or decreases from device to device, For example, Tablets, Smartphones, etc. The Pure.CSS Horizontal-to-Scrollabl
4 min read
Pure CSS Scrollable Horizontal Menu
When there isn't enough room, the scrollable horizontal menu items can be used. It gives responsiveness to the web pages. To create a scrollable horizontal menu, add the pure-menu-scrollable class. Pure.CSS provides vertical menus by default. You can change the vertical menu to a horizontal menu by adding the class name pure-menu-horizontal dropdow
3 min read
Pure CSS Table with Horizontal Borders
A table is an arrangement of data in rows and columns, or possibly in a more complex structure. Tables are widely used in communication, research, and data analysis. In Pure CSS, we will add a "pure-table" class to add styles to the table. This class adds padding and borders to table elements and emphasizes the header. A table with Horizontal Borde
2 min read
How to design a dropdown menu using pure CSS ?
The Dropdown Menu is a common UI pattern that we have seen on the web nowadays. It is useful in displaying related information in pieces without overwhelming the user with buttons, texts, and options. Most of the time it is seen inside the navigation bar or headers of websites. With the help of Pure CSS, we can easily create such dropdown menus. Ap
3 min read
Pure CSS Vertical Menu with Submenus
Menus are the main tools for visitors to navigate throughout a website. Pure.CSS comes up with very simple vertical and horizontal menus that can be easily customized by the developer. Vertical Menu with Submenus is as similar as nested vertical menu. Pure CSS Vertical Menu Classes: pure-menu-heading: It is the class that is added for the headings
5 min read
Pure CSS Scrollable Vertical Menu
Scrollable vertical menus are very useful to make our web pages compact, as it may not be feasible to show all the list items which would take up the entire height of the viewport. Let us create a scrollable vertical menu using pure CSS. Below mentioned and described the classes that are required to create this layout. pure-menu: It is the default
2 min read
Pure CSS Responsive Side Menu Layout
Pure CSS is a free and open-source CSS framework. It is a set of tools for building responsive websites and web applications. This was created by Yahoo and is used to create websites that are more responsive, attractive, and speedy. It serves as a strong substitute for Bootstrap. Pure CSS was created with consideration for responsive design. We thu
5 min read
How to Create Scrollable Horizontal Menu using CSS ?
In this article, we are going to implement a Scrollable Horizontal Menu using CSS. Approach: Scrollable Horizontal Menu is used to scroll the horizontal navbar using CSS "overflow:auto" and "white-space: nowrap". These two attributes are used to scroll the horizontal menu. To implement the scrollable horizontal menu You have to add HTML.You have to
1 min read
three90RightbarBannerImg