The Wayback Machine - https://web.archive.org/web/20241107000357/https://www.geeksforgeeks.org/how-to-create-right-aligned-menu-links-using-html-and-css/
Open In App

How to create Right Aligned Menu Links using HTML and CSS ?

Last Updated : 21 Nov, 2019
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The right-aligned menu links are used on many websites. Like hotels website that contains lots of options in the menu section but in case of emergency to make contact with them need specific attention. In that case, you can put all the menu options on the left side of the navigation bar and display contact us option on the right side of the bar. This design will make the website more attractive than the regular menu links. To create the right align menu links you just need HTML and CSS. Menu links should contain an important menu list that you want to display on the right side. The below example will illustrate the approach of the concept.

Creating the Structure: In this section, we will create a basic website structure to create a right-aligned menu links.

  • HTML code to make the structure:




    <!DOCTYPE html>
    <html>
      
    <head>
        <title>
            How To Create Right Aligned Menu
            Links using HTML and CSS ?
        </title>
          
        <meta name="viewport"
            content="width=device-width, initial-scale=1">
    </head>
      
    <body>
          
        <!-- Navbar items -->
        <div id="navlist">
            <a href="#">Home</a>
            <a href="#">Our Products</a>
            <a href="#">Careers</a>
            <div class="navlist-right">
            <a href="#">About Us</a>
            <a href="#">Contact Us</a>
            </div>
        </div>
      
        <!-- logo with tag -->
        <div class="content">
            <h1 style="color:green; padding-top:40px;">
                GeeksforGeeks
            </h1>
          
            <b>A Computer Science Portal for Geeks</b>
              
            <p>
                How many times were you frustrated while
                looking out for a good collection of
                programming/algorithm/interview questions?
                What did you expect and what did you get?
                This portal has been created to provide
                well written, well thought and well
                explained solutions for selected questions.
            </p>
        </div>
    </body>
      
    </html>

    
    

Designing the Structure: In the previous section, we have created the structure of the basic website. In this section, we will design the structure for the navigation bar.

  • CSS code of structure:




    <style>
               
        /* styling navlist */
        #navlist {
            background-color: #0074D9;
            position: absolute;
            width: 100%;
        }
               
        /* styling navlist anchor element */
        #navlist a {
            float:left;
            display: block;
            color: #f2f2f2;
            text-align: center;
            padding: 12px;
            text-decoration: none;
            font-size: 15px;
        }
        .navlist-right{
            float:right;
        }
       
        /* hover effect of navlist anchor element */
        #navlist a:hover {
            background-color: #ddd;
            color: black;
        }
    </style>

    
    

Combining the HTML and CSS code: This is the final code after combining the above two sections. You can see that Home, Careers and Our Products align-left as default but About us and Contact us aligned right.




<!DOCTYPE html>
<html>
  
<head>
    <title>
        How To Create Right Aligned Menu
        Links using HTML and CSS ?
    </title>
      
    <meta name="viewport"
        content="width=device-width, initial-scale=1">
          
    <style>
           
        /* styling navlist */
        #navlist {
            background-color: #0074D9;
            position: absolute;
            width: 100%;
        }
           
        /* styling navlist anchor element */
        #navlist a {
            float:left;
            display: block;
            color: #f2f2f2;
            text-align: center;
            padding: 12px;
            text-decoration: none;
            font-size: 15px;
        }
        .navlist-right{
            float:right;
        }
   
        /* hover effect of navlist anchor element */
        #navlist a:hover {
            background-color: #ddd;
            color: black;
        }
    </style>
</head>
  
<body>
      
    <!-- Navbar items -->
    <div id="navlist">
        <a href="#">Home</a>
        <a href="#">Our Products</a>
        <a href="#">Careers</a>
        <div class="navlist-right">
        <a href="#">About Us</a>
        <a href="#">Contact Us</a>
        </div>
    </div>
  
    <!-- logo with tag -->
    <div class="content">
        <h1 style="color:green; padding-top:40px;">
            GeeksforGeeks
        </h1>
      
        <b>A Computer Science Portal for Geeks</b>
          
        <p>
            How many times were you frustrated while
            looking out for a good collection of
            programming/algorithm/interview questions?
            What did you expect and what did you get?
            This portal has been created to provide
            well written, well thought and well
            explained solutions for selected questions.
        </p>
    </div>
</body>
  
</html>


Output:



Previous Article
Next Article

Similar Reads

How to make div with left aligned text and right aligned icon using CSS ?
Creating a div with left-aligned text and a right-aligned icon in CSS involves arranging elements within a container so that the text is positioned on the left side while the icon is placed on the right. This layout is commonly used for navigation bars, buttons, and list items, enhancing both functionality and aesthetics. Properties Useddisplay: To
2 min read
Primer CSS Select Menu Right aligned
Primer CSS is a free and open-source CSS framework that is built using the GitHub design system for providing support to the broad spectrum of GitHub websites. It helps in creating the foundation of the basic style elements such as spacing, components, typography, color, etc. In this article, we'll see about Primer CSS Select Menu Right aligned. A
2 min read
Primer CSS Right Aligned
Primer CSS is a free open-source CSS framework that is built upon systems that create the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by Object-Oriented CSS principles, functional CSS, an
2 min read
Bulma Right aligned Dropdown
Bulma is a CSS framework that can be used as an alternative to Bootstrap. It is based on flexbox. In this article, we will be seeing how to make a dropdown right-aligned in Bulma. To make a dropdown right-aligned, we just have to add the is-right modifier to the dropdown container. Bulma Right Aligned Dropdown Classes: is-right: This class is used
2 min read
How to make an image center-aligned (vertically & horizontally) inside a bigger div using CSS ?
We will know how to center-align the image in a div tag using CSS & will also understand its implementation through the example. Given an image, we need to set the image that align to the center (vertically and horizontally) inside a bigger div. But first let's create a basic structure, in which inside the body tag with id=outer there is an img
2 min read
Difference between normal links and active links
Websites are designed to point you to different resources. You can move from one website to another through links. Links help you to get information from different resources. Links are established in simple HTML web pages through <a> tag.Links are categorized into three types. Typically a Link is displayed in three different colors based on t
2 min read
Pure CSS Aligned Form
Pure CSS is a framework of CSS. It is a free and open-source tool collection for creating responsive websites and web applications. Pure CSS is developed by Yahoo and is used for creating faster, more beautiful, and more responsive websites. It can be used as an alternative to Bootstrap. Pure CSS Aligned Form is a type of HTML form that is used to
2 min read
How to create animated banner links using HTML and CSS?
Links are one of the most important parts of any component that is used in website making. Almost every component had some form of links in it. A common example is a menu/nav-bar. All we see is some button like home, about, etc. but under the hood they all are links. Sometimes there comes a situation where you don't want to wrap the link inside a b
2 min read
Foundation CSS Menu Vertical Menu
Foundation CSS is an open-source & responsive front-end framework built by ZURB foundation in September 2011, that makes it easy to design beautiful responsive websites, apps, and emails that look amazing & can be accessible to any device. It is used by many companies such as Facebook, eBay, Mozilla, Adobe, and even Disney. The framework is
2 min read
How to set horizontal aligned accordion in Bootstrap 4 ?
Accordion vertical is quite popular in web development, but horizontal accordion is required in few cases to that in this article we will use pointer-events. We will take the writing mode to change the accordion title view. And use the transform to rotate the whole accordion. Below program illustrates the above approach: Program: C/C++ Code <!DO
2 min read
Semantic-UI Search Aligned Variation
Semantic UI open-source framework gives icons or glyphs that are used to show pictures related to some elements using CSS and jQuery that is used to create great user interfaces. It is a development framework used to create beautiful and responsive layouts. Semantic UI Search is used to allow the user to search different things on the website. The
2 min read
Semantic-UI Image Vertically Aligned Variations
Semantic UI is an open-source development framework that provides pre-defined classes to make our website look beautiful, amazing, and responsive. It is similar to Bootstrap which has predefined classes. It uses jQuery and CSS to create the interfaces. It can also be directly used via CDN like bootstrap. There are different styles of putting images
2 min read
Semantic-UI List Vertically Aligned Content Variation
Semantic UI is an open-source development framework that provides pre-defined classes to make our website look beautiful, amazing, and responsive. It is similar to Bootstrap which has predefined classes. It uses jQuery and CSS to create the interfaces. It can also be directly used via CDN like bootstrap. Semantic-UI list provides us with different
2 min read
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 create it simply by using HTML and CSS. We will creat
2 min read
How to create a mega menu using HTML and CSS ?
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
4 min read
Create A Custom Select Menu with Search Box using HTML CSS and JavaScript
This article will show you how to create a custom select menu with a search box using HTML, CSS, and JavaScript. First, we create an option list for the select box, and we can search for text in the text input box. The search result displays the matched option value. Additionally, we have added a "clear" button to remove your latest search. Approac
5 min read
Create a Curtain Menu using HTML and CSS
This article will show you how to create a Curtain menu navbar effect with the help of HTML and CSS. The curtain menu means revealing or pulling down the menu items like a curtain. HTML is used to create the structure of the curtain menu and applies styles on that element to make like curtain menu effect. Also, we will add a close button to the cor
3 min read
Create A Bottom Navigation Menu using HTML and CSS
This article will show you how to create a bottom navigation menu using HTML and CSS. The navigation menu is an essential component in modern web design. It allows users to navigate through a website easily. Here, we use HTML to create the structure of the Bottom Navigation menu, and CSS add styles to the elements. Example 1: In this example, we wi
2 min read
Create a Mobile Toggle Navigation Menu using HTML, CSS and JavaScript
To create a Mobile Toggle Navigation Menu you need HTML, CSS, and JavaScript. If you want to attach the icons with the menu then you need a font-awesome CDN link. This article is divided into two sections: Creating Structure and Designing Structure. A glimpse of complete Navigation:  Creating Structure: In this section, we will create a basic site
3 min read
How to avoid Dropdown Menu to Close menu Items on Clicking Inside?
Prevent a dropdown menu from closing when clicked inside by using the stopPropagation() method. This method ensures the menu stays open, allowing users to interact with the menu items without it closing unexpectedly. stopPropagation()The stopPropagation() method is used to stop propagation of event calling i.e. the parent event is called we can sto
2 min read
How to Create Links to Other Pages in HTML ?
HTML links are like pathways on the internet. They connect one webpage to another. Imagine a link as having two parts: a starting point (where you click) and an endpoint (where you end up). When you click on a link, you're basically starting at one point (the anchor) and moving to another (the destination). These links are made using anchor tags in
2 min read
How to create links to sections within the same page in HTML ?
We will explore how to create links within an HTML page that are linked to specific sections of the same page. Creating internal links in HTML enhances user experience by making navigation easier for website visitors. By using the id attribute and the <a> (anchor) tag, you can link to specific sections of a webpage, allowing quick access to n
2 min read
How to create lists and links using jQuery EasyUI Mobile ?
In this article we will learn how to design lists, group them and create links for easy navigation using jQuery EasyUI Mobile. EasyUI is a HTML5 framework for using user interface components based on jQuery, React, Angular and Vue technologies. It helps in building features for interactive web and mobile applications saving a lot of time for develo
4 min read
How to design menu on right click of webpage using jQuery EasyUI ?
EasyUI is a HTML5 framework for using user interface components based on jQuery, React, Angular and, Vue technologies. It helps in building features for interactive web and mobile applications saving a lot of time for developers. It helps in building features for interactive web and mobile applications saving a lot of time for developers. Download
3 min read
How to Remove Firefox's Dotted Outline on Buttons and links using CSS ?
In Firefox browser, dotted outline appears around the buttons, links as well as inputs. The ability to tell which piece is now in focus makes this outline useful for people who browse the web using a keyboard. This is a feature of Firefox's accessibility tools, which seek to make it simpler for users to navigate online pages using keyboard shortcut
3 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 and UI. A sidebar menu enhances website UX, offerin
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 create a Menu Icon using CSS. The article contains
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 links such as Home, About Us, Contact, etc. Preview
3 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
How To Create A Dropup Menu Using CSS?
A Dropup menu is a type of menu in web design that expands upwards from its trigger element instead of the traditional dropdown direction. Dropup menus are often used in contexts such as navigation bars, form selections, and interactive elements. Below are the approaches used for creating the dropup menu using CSS Table of Content Using Basic CSS M
6 min read
three90RightbarBannerImg