CSS Lists
-
Learn CSS list styling to customize markers, spacing, and layout for ordered and unordered lists.
In HTML, lists are used to display multiple items in a structured and meaningful way.
There are two commonly used list types:
• Unordered List (<ul>) → bullets
• Ordered List (<ol>) → numbersBy default, browsers apply:
• Bullets or numbers
• Indentation
• Basic spacingIn simple words:
CSS list styling gives you full control over how lists look and behave.
Why Do We Style Lists in CSS ?
Without styling:
Lists look basic and outdated
Not suitable for navigation or menusWith CSS list styling:
Clean and modern UI
Professional navigation bars
Fully custom designsReal-life comparison:
A neatly printed restaurant menu looks far better than rough handwritten notes.CSS List Styling Properties
Removing Default Bullets
Why remove bullets ?
Bullets are unnecessary for:
• Navigation menus
• Website headers
• Horizontal menus
Removing Default List Bullets
list-style: none; removes default bullets from lists, making them suitable for navigation menus and custom layouts.
ul {
list-style: none;
padding: 0;
margin: 0;
}
Removes bullets
Real-life comparison:
Removes default indentation
Removing unnecessary symbols from a clean menu card.Custom List Markers
Instead of default bullets, you can apply custom markers.
Custom List Markers
list-style-type changes the default bullet style to built-in marker types like square, circle, or numbers.
ul {
list-style-type: square;
}
Other values include:
• circle
• disc
• decimal
• lower-alpha
• upper-romanCustom Symbols (Advanced Technique)
Custom List Symbols with ::before
Using ::before allows you to add custom symbols before list items instead of default bullets.
li::before {
content: "✔ ";
color: green;
}
Fully customizable
Real-life comparison:
Modern checklist appearance
Using icons instead of dots in a task checklist.Horizontal Menus Using Lists
Lists are widely used to create horizontal navigation menus.
Horizontal Menu Using Lists
Lists can be styled with display: inline-block; to create horizontal navigation menus.
<!DOCTYPE html>
<html>
<head>
<title>Horizontal Menu Example</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 40px;
}
.menu {
list-style: none;
padding: 0;
margin: 0;
}
.menu li {
display: inline-block;
margin-right: 20px;
}
</style>
</head>
<body>
<ul class="menu">
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Contact</li>
</ul>
</body>
</html>
Items appear side-by-side
Perfect for navigation barsReal-life comparison:
Menu items displayed neatly in one line.Clickable List Menus
Lists are commonly combined with links to create real navigation bars.
Clickable Navigation Menu
Lists combined with anchor () tags create real, clickable navigation menus for websites.
<!DOCTYPE html>
<html>
<head>
<title>Clickable Navigation Menu</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 40px;
}
.nav {
list-style: none;
padding: 0;
margin: 0;
}
.nav li {
display: inline-block;
}
.nav a {
text-decoration: none;
padding: 10px 15px;
color: black;
display: inline-block;
}
.nav a:hover {
background-color: #333;
color: white;
}
</style>
</head>
<body>
<ul class="nav">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</body>
</html>
- Clean navigation
Larger clickable area
User-friendly design
Hover Effect on Navigation Links
:hover adds interactive styling to menu links when the user moves the mouse over them.
.nav a:hover {
background-color: #333;
color: white;
}
Clear visual feedback
Improves user confidenceReal-life comparison:
Buttons changing appearance when touched.Where CSS Lists Are Used
Navigation Bars
Most website menus are built using lists.
Structured
Real-life comparison:
Easy to manage
Accessible
Road signs guiding users clearly.Menus (Dropdowns, Sidebars, Footers)
Lists are used in:
• Sidebar menus
• Dropdown menus
• Footer navigationReal-life comparison:
Options list in a mobile application.Content Lists
Lists are also useful for content such as:
• Feature lists
• Step-by-step instructions
• Checklists
Styling Content Lists
Lists can be styled for content like features, steps, or checklists by adjusting spacing and layout.
.features li {
margin-bottom: 10px;
}
Improves readability
Better spacingControlling List Spacing
By default, lists have extra spacing.
Controlling List Spacing
Removing default padding from lists improves spacing and readability.
ul {
padding-left: 0;
}
Full control over alignment
Cleaner layoutCommon Mistakes
Forgetting to remove default padding
Leaving bullets in navigation menus
Using lists incorrectly for page layout
Ignoring hover and focus effectsBest Practices for CSS Lists
Remove bullets for navigation menus
Use lists for menus (semantic HTML)
Add padding for better click areas
Maintain consistent spacing
Always include hover and focus stylesLists represent structured items
CSS provides control and customization
Well-styled lists create professional interfacesCSS lists are essential for menus and navigation
Bullets can be removed or fully customized
Lists can be turned into horizontal menus
Widely used in headers, sidebars, and layouts
A core skill for front-end development