4 CSS Nested Lists: Free Code Snippets & Examples
Nested lists encode hierarchy through indentation — each level visually communicates parent-child relationships without additional explanatory text. CSS nested lists leverage automatic counter-based numbering and connector lines to create tree structures that are both semantically rich and visually clear.
- Each nesting level uses
counter-resetwithcounter-incrementscoped to the<ol>or<ul>depth, producing automatic hierarchical numbering (1,1.1,1.2) that updates dynamically as items are added or reordered. - Connector lines between parent and child items are drawn using
::beforepseudo-elements withborder-leftandborder-bottom, creating visual tree branches that require zero additional HTML markup. - Semantic HTML with properly nested
<ul>and<li>elements ensures screen readers announce the list depth and position, whilearia-levelprovides explicit hierarchy context when needed.
Browse the collection to find a nested list format that fits your hierarchical data — from documentation outlines with automatic section numbering to file tree navigators with expandable branches.
Table of Contents:
Examples

Pure CSS ASCII File Tree
This Pure CSS ASCII File Tree brings the nostalgia of command-line directory structures to the web without typing a single pipe character manually. By cleverly utilizing CSS pseudo-elements (::before), it automatically draws the connecting lines (│, ├, └) for nested lists. It’s perfect for technical documentation, sitemaps, or retro-themed interfaces.
See the Pen Pure CSS ASCII File Tree.

Nested List Style
An elegant, modern list of track properties featuring custom graphic icons and smooth micro-interactions like padding shifts and color changes on hover.
See the Pen Nested List Style.

OST Tree
A pure CSS tree diagram constructed from nested lists where pseudo-elements with borders form the connecting branches.
See the Pen OST Tree.

List Styles
An aesthetically pleasing, modern todo list featuring a vibrant gradient theme and an intuitive hierarchy creation function without complex control buttons.
See the Pen List Styles.