w1coding.comAll tutorials

CSS Navigation

CSS lessons
  1. Environment Setup
  2. Introduction
  3. Tdisplay
  4. Basics
  5. Editors
  6. Syntax
  7. Colors
  8. Background
  9. Borders
  10. Margins
  11. Padding
  12. Width And Height
  13. Outline
  14. Texts
  15. Fonts
  16. Icons
  17. Links
  18. Lists
  19. Display
  20. Tables
  21. Max And With
  22. Positon
  23. Z Index
  24. Dropdown
  25. Overflow
  26. Float
  27. Navigation
  28. Image Sprites

Introduction to CSS Navigation Bar

CSS can be used to style navigation bars, which are typically used for site menus and links to various sections of a website.

Basic Navigation Bar Styling

  • Use a ul element to create the structure of the navbar.
  • Style links with display: inline-block to position them horizontally.
  • Add padding and background color to enhance the design.

Example


nav ul {
    list-style-type: none;
    padding: 0;
    background-color: #333;
}
nav ul li {
    display: inline-block;
}
nav ul li a {
    color: white;
    padding: 15px;
    text-decoration: none;
}
nav ul li a:hover {
    background-color: #111;
}
        

Browser Support

Supported by all modern browsers.