LESSON 6.3
Navigation in an Unordered List
Build a clean horizontal nav bar from a simple list
Learn how to structure a navigation menu using an HTML unordered list and transform it from a bulleted vertical list into a clean horizontal nav bar with CSS.
💡 The Concept
A website navigation menu is fundamentally a list of links. An unordered list is the right HTML structure for this because it signals to browsers, screen readers, and search engines that the links belong together as a group. CSS then handles the visual presentation. This lesson covers the HTML structure and basic styling. Navigation is not truly complete without hover and active states, which are covered in the next lesson: CSS Pseudo-Classes for Navigation.
Here is the basic HTML structure for a navigation menu:
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="menu.html">Menu</a></li>
<li><a href="directions.html">Directions</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
When you first preview this in the browser, you get a bulleted vertical list of blue underlined links. Here is the CSS that transforms it into a horizontal navigation bar:
nav ul {
list-style-type: none; /* removes the bullets */
}
nav a {
text-decoration: none; /* removes the underlines */
padding-right: 10px; /* spaces the links apart */
}
nav li {
display: inline; /* places items side by side */
}
The exercise below walks through each of these steps one at a time so you can see the effect of each change.
🎬 Video Demonstration
This video walks through building a vertical and horizontal navigation menu using an unordered list.
Exercise: Try It Yourself
Step 1. Open JSFiddle.
Step 2. Convert the starting code below to a proper ul / li structure. Add <ul> and <li> tags around the links and run it in JSFiddle.
<nav>
<a href="index.html">Home</a>
<a href="menu.html">Menu</a>
<a href="directions.html">Directions</a>
<a href="contact.html">Contact</a>
</nav>

At this stage it does not look like a menu — it looks like a bulleted list of links.
Step 3. Use list-style-type: none on the ul to remove the bullets, and text-decoration: none on the anchor tags to remove the underlines:
nav ul {
list-style-type: none;
}
nav a {
text-decoration: none;
}

This is what a vertical navigation looks like — bullets and underlines removed, but the links still stack vertically.
Step 4. By default, li elements are block-level, so each one sits on its own line. Set display: inline to place them side by side, and add right padding to space them out:
nav li {
display: inline;
}
nav a {
padding-right: 10px;
}

Now it looks like a navigation bar.
Save this JSFiddle. We have more work to do on this navigation. In the next lesson, we will add pseudo-class styling to make the links respond to hover and click.
💡 If you are making a website template: Convert the navigation in your website template from plain links to an unordered list. See the full website template guide for reference.
❓ Frequently Asked Questions
Plain anchor tags in a row work visually, but they carry no semantic meaning — the browser, screen reader, and search engine just see a collection of unrelated links. Wrapping them in a ul inside a nav element tells those tools that the links are a navigation group. Screen readers will announce how many items are in the list, which helps users who cannot see the visual layout. Search engines also use this structure to better understand your site.
The nav element is a semantic landmark that specifically marks a block of navigation links. A div would work visually, but nav communicates purpose. Screen readers use landmarks to let users jump directly to navigation without reading through other content first. You do not need nav around every group of links — just the main navigation menus on the page.
Both place elements side by side, but inline-block lets you set top and bottom padding and a specific width, while inline does not. For simple horizontal navigation, display: inline works fine. If you need to give each nav item a consistent height, background color, or vertical padding — like styled buttons — inline-block gives you more control. A later lesson will also cover using flexbox on the ul itself, which is a more modern approach to horizontal layouts.
No. Vertical navigation is common for sidebar menus and mobile layouts. The unstyled list is already vertical — that is the default. You only add display: inline when you want a horizontal bar. Many sites use horizontal navigation on desktop and switch to vertical (or a hamburger menu) on mobile using media queries. That technique is covered in later lessons.
★ Key Takeaways
Navigation menus are really just styled lists. This lesson showed you how to take an unordered list and turn it into a horizontal navigation bar using CSS. Next, you will add CSS pseudo-classes to your navigation to create hover and active states. Those states make navigation feel interactive and polished.
Google Ads
The costs of this website are partially offset by revenue from Google Ads.Tools of the Trade
HTML/CSS Lessons
-
-
-
1.3. HTML Tag Preview
-
-
-
2.2. The HTML Framework
-
-
2.4. HTML Headings
-
-
-
-
-
-
3.01. Introduction to CSS
-
3.02. How CSS Cascades
-
-
-
-
3.05. CSS Colors
-
3.06. RGBA Colors
-
-
3.08. Font and Text Properties
-
3.09. Classes and IDs
-
-
-
-
-
4.3. HTML Embedded Images
-
-
-
-
-
-
5.1. CSS Borders
-
5.2. CSS Border Radius
-
5.3. CSS Gradients
-
5.4. CSS Box Shadows
-
5.5. CSS Text Shadows
-
7.1. The Display Property
-
-
-
7.4. The Box Model
-
-
-
-
-
-
9.1. Website Tables
-
9.2. HTML Forms
-
-
9.4. Special Form Fields
-
9.5. Embedding Multimedia
-
-
9.7. Keyboard Shortcuts
-
10.1. What Is a Framework?
-
10.2. Font Awesome Icons
-
-
10.4. Bootstrap Grid System
-
-
10.6. Bootstrap Navigation
-
-
11.2. Purchasing a Domain Name
-
11.3. Website Hosting
-
11.4. Nameservers and DNS
-
11.5. FTP
-
11.6. GitHub Pages
