
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a navigation bar with equal-width navigation links with CSS?
Following is the code to create a navigation bar with equal-width navigation 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; } *,*::before,*::after{ box-sizing: border-box; } nav{ position: fixed; top: 0; width: 100%; background-color: rgb(39, 39, 39); overflow: auto; height: auto; } .links { width: 20vw; padding: 17px; display: inline-block; text-align: center; color: rgb(178, 137, 253); text-decoration: none; font-size: 17px; } .links:hover { background-color: rgb(100, 100, 100); } .selected{ background-color: rgb(0, 18, 43); } </style> </head> <body> <nav> <a class="links selected" href="#">Home</a> <a class="links" href="#">Login</a> <a class="links" href="#">Register</a> <a class="links" href="#">Contact Us</a> <a class="links" href="#">More Info</a> </nav> <h1>Equal width navigation menu</h1> </body> </html>
Output
The above code will produce the following output −
- Related Questions & Answers
- Center links in a Navigation Bar with CSS
- Create a Horizontal Navigation Bar with CSS
- How to create a dropdown navigation bar with CSS?
- How to create a navigation bar with left-aligned and right-aligned links with CSS?
- How to create bottom bordered (underline) navigation links with CSS?
- Build a Vertical Navigation Bar with CSS
- How to create a responsive navigation bar with dropdown in CSS?
- How to create a navigation bar with a centred link/logo with CSS?
- How to Create an On Scroll Fixed Navigation Bar with CSS?
- How to create a breadcrumb navigation with CSS?
- How to create a mega menu (full-width dropdown menu in a navigation bar) with HTML and CSS?
- How to create a bottom navigation menu with CSS?
- How to create a pill navigation menu with CSS?
- How to add link dividers in a Navigation Bar with CSS
- How to create a fixed side navigation menu with CSS?
Advertisements