22 min read
Styling the Navigation Bar
Turn a bulleted list of links into a horizontal bar with hover and active states.
From List to Bar in Five Steps
The navigation is an unordered list of links. Kasun styles it step by step:
- Remove the bullets and default spacing:
list-style: none; margin: 0; padding: 0; - Put the items in a row:
display: flex;on the ul, with agapbetween items. - Make each link a comfortable button: padding, no underline, light text.
- Add a hover colour so visitors know they can click.
- Mark the current page with the class
active.
What the browser shows
Try it: Hover over the links. Delete display: flex from nav ul and see the list become vertical again. Change which link has class="active".
What Each Part Does
| Navigation rules explained | |
|---|---|
Practice
Which rule makes navigation list items sit side by side?
More lessons in CSS · Next: Styling the Header and Footer · Previous: Spacing, Borders and Sizing
