Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Lesson 5 of 10
CSS Lists & List Styling
Lists are used everywhere - navigation menus, feature lists, footers, sidebars. CSS lets you customize bullets, numbering, spacing, and create horizontal lists for navigation.
List Properties
- list-style-type - disc (default), circle, square, decimal, lower-alpha, none (removes bullets/numbers)
- list-style-position - outside (default, indented bullets) vs inside (bullets inside content area)
- list-style-image - Custom bullet: list-style-image: url('bullet.svg')
- list-style: none - Removes all bullets/numbers. Essential for nav menus built with <ul>
- ::marker pseudo-element - Style the bullet/number directly: color, font-size, content
- Horizontal list - display: flex on <ul> turns vertical list into horizontal nav
- Custom bullets with ::before - More control than list-style: use content: 'โ' or emojis
List Styling Code
/* Remove default list styles for navigation */
.nav-list {
list-style: none;
padding: 0;
margin: 0;
display: flex;
gap: 24px;
}
/* Custom bullet points */
.feature-list {
list-style: none;
padding: 0;
}
.feature-list li {
padding: 8px 0 8px 28px;
position: relative;
}
.feature-list li::before {
content: 'โ';
color: #2ecc71;
font-weight: bold;
position: absolute;
left: 0;
}
/* Styled marker */
.custom-markers li::marker {
color: #E44D26;
font-size: 1.2em;
}
/* Numbered steps */
.steps {
counter-reset: step;
list-style: none;
padding: 0;
}
.steps li::before {
counter-increment: step;
content: counter(step);
background: #E44D26;
color: white;
width: 28px;
height: 28px;
border-radius: 50%;
display: inline-flex;
align-items: center;
justify-content: center;
margin-right: 12px;
font-weight: bold;
font-size: 0.85em;
}Tip
CSS counters (counter-reset + counter-increment + content: counter()) let you create custom-styled numbered lists with circles, colors, and sizes that list-style can't achieve. This is the professional technique behind beautiful step-by-step tutorial sections.
Customize ordered and unordered lists with custom markers and positioning rules
Common Mistake
Forgetting to remove both list-style AND default padding when building navbars from <ul>. Browsers add around 40px of padding-left to lists. Always pair list-style: none with padding: 0; margin: 0 for a truly clean starting point.
Practice Task
Convert a plain <ul> into a feature checklist: (1) Remove default bullets. (2) Add a green checkmark โ before each item with li::before { content: 'โ'; color: #2ecc71; }. (3) Then create a separate numbered list using CSS counters that displays circular step numbers.
Quick Quiz
Key Takeaways
- Lists are used everywhere - navigation menus, feature lists, footers, sidebars.
- list-style-type - disc (default), circle, square, decimal, lower-alpha, none (removes bullets/numbers)
- list-style-position - outside (default, indented bullets) vs inside (bullets inside content area)
- list-style-image - Custom bullet: list-style-image: url('bullet.svg')
Finished this lesson?