Skip to content

Buzzingz

Unleashing the Power of Code

  • HTML
  • CSS
  • Toggle search form

CSS Navigation Bar

Posted on March 15, 2023March 15, 2023 By shani No Comments on CSS Navigation Bar

A navigation bar, also known as a navbar or menu bar, is an important component of a website’s user interface. It is usually located at the top of the webpage and contains links to various sections of the website.

Here is an example of a simple navigation bar using HTML and CSS:

HTML:

<nav>
  <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Services</a></li>
    <li><a href="#">Contact</a></li>
  </ul>
</nav>

CSS:

nav {
  background-color: #333;
  overflow: hidden;
}

nav ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

nav li {
  float: left;
}

nav li a {
  display: block;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

nav li a:hover {
  background-color: #111;
}

In the above example, the nav element is used to create the navigation bar. The ul element is used to create an unordered list of links, and the li element is used to create each individual link.

The CSS styles set the background color of the navigation bar to #333 and use the overflow: hidden property to ensure that any content inside the navbar doesn’t overflow beyond its boundaries. The list-style-type, margin, and padding properties are used to style the unordered list, while the float property is used to align the links horizontally. The a element is styled to have white text, a centered text alignment, and a padding of 14px on top and bottom and 16px on the left and right. The :hover pseudo-class is used to change the background color of the links when the user hovers over them.

This is just one example of how to create a navigation bar in CSS. There are many different styles and designs that can be used depending on the website’s branding and design.

CSS

Post navigation

Previous Post: CSS Opacity / Transparency
Next Post: CSS Vertical Navigation Bar

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CSS Tutorial

  • Basic CSS Tutorial For Beginners
  • CSS Introduction
  • CSS Syntax
  • CSS Selectors
  • How To Add CSS
  • CSS Comments
  • CSS Colors
  • CSS Backgrounds
  • CSS Borders
  • CSS Margins
  • CSS Margin Collapse
  • CSS Padding
  • CSS Height, Width and Max-width
  • CSS Box Model
  • CSS Outline
  • CSS Text
  • CSS Fonts
  • CSS Web Safe Fonts
  • CSS Font Fallbacks
  • CSS Font Style
  • CSS Font Size
  • CSS Google Fonts
  • CSS Great Font Pairings
  • CSS Icons
  • CSS Links
  • CSS Lists
  • CSS Tables
  • CSS Layout – display: inline-block
  • CSS Layout – float and clear
  • CSS Layout – Horizontal & Vertical Align
  • CSS Layout – Overflow
  • CSS Layout – The display Property
  • CSS Layout – The z-index Property
  • CSS Layout – width and max-width
  • CSS Layout – The position Property
  • CSS Attribute Selectors
  • CSS Image Sprites
  • CSS Image Gallery
  • CSS Dropdowns
  • CSS Horizontal Navigation Bar
  • CSS Vertical Navigation Bar
  • CSS Navigation Bar
  • CSS Opacity / Transparency
  • CSS Pseudo-elements
  • CSS Pseudo-classes
  • CSS Combinators
  • CSS Math Functions
  • CSS The !important Rule
  • CSS Specificity
  • CSS Units
  • CSS Website Layout
  • CSS Counters
  • CSS Forms
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms & Conditions

Copyright © 2023 Buzzingz.

Powered by PressBook WordPress theme