
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
How to create a navigation bar with left-aligned and right-aligned links with CSS?
Following is the code to create a navigation bar with left-aligned and right-aligned links −
Example
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> body{ margin:0px; margin-top:60px; padding: 0px; } nav{ display: flex; position: fixed; top:0; width: 100%; background-color: rgb(251, 255, 196); overflow: auto; height: auto; } .left-links{ flex:1 1 200px; } .links { display: inline-block; text-align: center; padding: 14px; color: rgb(0, 0, 0); text-decoration: none; font-size: 17px; font-weight: bolder; } .links:hover { border-bottom: 2px solid purple; } .selected{ border-bottom: 2px solid purple; } </style> </head> <body> <nav> <div class="left-links"> <a class="links selected" href="#">Home</a> <a class="links" href="#"> Login</a> <a class="links" href="#"> Register</a> </div> <div class="right-links"> <a class="links" href="#"> Contact Us</a> <a class="links" href="#">More Info</a> </div> </nav> <h1>Hover on the above links</h1> </body> </html>
Output
The above code will produce the following output −
- Related Articles
- How to create a navigation bar with equal-width navigation links with CSS?
- Make a left-aligned with Bootstrap
- Center links in a Navigation Bar with CSS
- How to create a dropdown navigation bar with CSS?
- How to create bottom bordered (underline) navigation links with CSS?
- Create a Horizontal Navigation Bar with CSS
- How to create a navigation bar with a centred link/logo with CSS?
- How to create a responsive navigation bar with dropdown in CSS?
- How to Create an On Scroll Fixed Navigation Bar with CSS?
- Build a Vertical Navigation Bar with CSS
- How to create a breadcrumb navigation with CSS?
- How to resize a navigation bar on scroll with CSS and JavaScript?
- How to create a Vertical Navigation Bar using HTML and CSS ?
- Show flex items right aligned and horizontally in Bootstrap
- How to add link dividers in a Navigation Bar with CSS

Advertisements