Uncheck "normalize CSS" - http://jsfiddle.net/qGCUk/3/ The CSS reset used in that defaults all list margins and paddings to 0

UPDATE http://jsfiddle.net/qGCUk/4/ - you have to include your sub-lists in your main <li>

ol {
  counter-reset: item
}
li {
  display: block
}
li:before {
  content: counters(item, ".") " ";
  counter-increment: item
}
<ol>
  <li>one</li>
  <li>two
    <ol>
      <li>two.one</li>
      <li>two.two</li>
      <li>two.three</li>
    </ol>
  </li>
  <li>three
    <ol>
      <li>three.one</li>
      <li>three.two
        <ol>
          <li>three.two.one</li>
          <li>three.two.two</li>
        </ol>
      </li>
    </ol>
  </li>
  <li>four</li>
</ol>
Answer from Zoltan Toth on Stack Overflow
🌐
W3Schools
w3schools.com › html › html_lists_ordered.asp
HTML Ordered Lists
Use the HTML <ol> element to define an ordered list · Use the HTML type attribute to define the numbering type · Use the HTML <li> element to define a list item · Lists can be nested · List items can contain other HTML elements · For a ...
People also ask

How do I create a nested list in HTML?
To create a nested list, place a
    or
      element inside an
    1. element of another list. Ensure to properly close all tags and structure your list to enhance readability and accessibility.
🌐
dhiwise.com
dhiwise.com › post › how-to-create-nested-lists-in-html-a-simple-guide
HTML Nested Lists: A Simple Guide
How can I customize the appearance of nested lists with CSS?
You can customize nested lists using CSS properties such as list-style-type for changing bullet points, list-style-image for custom bullets, and pseudo-elements for adding icons or animations to list items.
🌐
dhiwise.com
dhiwise.com › post › how-to-create-nested-lists-in-html-a-simple-guide
HTML Nested Lists: A Simple Guide
Can I nest ordered lists inside unordered lists?
Yes, you can nest ordered lists (
    ) inside unordered lists (
      ) and vice versa. This allows for a flexible structure to suit the content and hierarchy of your information.
🌐
dhiwise.com
dhiwise.com › post › how-to-create-nested-lists-in-html-a-simple-guide
HTML Nested Lists: A Simple Guide
🌐
Mark
mark.ie › blog › nested-lists-in-css-with-a-numbered-hierarchy
Nested lists in CSS with a numbered hierarchy | Mark Conroy | Lead Frontend Drupal Developer
Using CSS, we can make nested ordered lists automatically display in a numbered hierarchy—like "1, 1.1, 1.2, 2, 2.1", without any additional HTML markup changes. Here’s how to set it up!
🌐
GeeksforGeeks
geeksforgeeks.org › html › nested-list-in-html
Nested List in HTML - GeeksforGeeks
July 23, 2025 - A nested list in HTML is a list that contains other lists within its list items. This creates a hierarchical structure, where each sublist is indented to visually represent its relationship to the parent list item.
🌐
Scaler
scaler.com › topics › nested-list-in-html
How to Create a Nested List in HTML? - Scaler Topics
October 18, 2022 - Always the first child of the <ul> tag will be a <li> tag after that, you can nest another <ul> or <ol> tag to create a nested ordered/unordered list. Note: Element <ul> is not allowed as child of element <ul>. We need to add a <li> enclosing to the children <ul> tags.
🌐
DhiWise
dhiwise.com › post › guide-to-creating-structure-content-using-html-ordered-lists
Creating Structured Content with HTML Ordered List
June 4, 2024 - For example, if you want to use ... numbering style within the same list. You can do this by nesting an <ol> element with a different type attribute inside your list....
🌐
W3Docs
w3docs.com › html
How to Display an Ordered List with Nested Counters
You can display an ordered list with nested counters like 1.1, 1.2 instead of 1, 2 by using CSS. In this snippet, you’ll find some methods of displaying such numbers. <!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> ol { counter-reset: item; } li { display: block; color: #666666; } li:before { content: counters(item, ".") " "; counter-increment: item; } </style> </head> <body> <ol> <li>Element 1 <ol> <li>Sub element 1</li> <li>Sub element 2</li> <li>Sub element 3</li> </ol> </li> <li>Element 2</li> <li>Element 3 <ol> <li>Sub element 1</li> <li>Sub element 2</li> <li>Sub element 3</li> </ol> </li> </ol> </body> </html>
Find elsewhere
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Reference › Elements › ol
<ol>: The Ordered List element - HTML | MDN
Typically, ordered list items display with a preceding marker, such as a number or letter. The <ol> and <ul> (or the synonym <menu>) elements may nest as deeply as desired, alternating between <ol>, <ul> (or <menu>) as needed.
🌐
DhiWise
dhiwise.com › post › how-to-create-nested-lists-in-html-a-simple-guide
HTML Nested Lists: A Simple Guide
September 30, 2024 - To output nested ordered lists, you can use HTML attributes like type, start, and reversed to control the formatting and structure, such as compactness, reversed ordering, and starting points.
🌐
Educative
educative.io › answers › how-to-create-a-nested-list-in-html
How to create a nested list in HTML
The nested ul represents an unordered list, and the inner li tag displays vegetables of each category. To create an ordered list in HTML, use the ol (ordered list) tag with the li (list item) tag in a hierarchical structure.
🌐
Knowledgeowl
support.knowledgeowl.com › help › customize-nested-numbered-list-styles
Customize nested numbered list styles | KnowledgeOwl Support
To achieve the list style above, use a counter within the numbered list, so that it numbers the 1.x and 1.1.x strings, etc., based on the count and position of the list items: Go to Customize > Style (HTML & CSS). In the Customize HTML, CSS, and JS section, select Custom CSS. Copy the CSS below and paste it into the CSS pane: /* Styles for formatting sub-ordered-list-items with 1.1., 1.1.1., etc.)*/ /* First, set all numbered lists to use counter-reset */ .hg-article-body ol { counter-reset: item; } /* Display all list items in a numbered list in block display */ .hg-article-body ol>li { display: block; } /* Use a counter that checks the number of items and adds a "." between them and ends with ".
🌐
TutorialsPoint
tutorialspoint.com › how-to-display-an-ordered-list-with-nested-counters
How to Display an Ordered List with Nested Counters?
In this snippet, we will discuss two methods for creating an ordered list with nested counters using the display property. An element with the display property set to block begins on a new line and occupies the entire screen width. For such elements, we can specify their width and height. Elements that are at the block level by default include <div>, <section>, <p>, and many others. We can make the span from the previous HTML code behave like a block-level element by setting it to block display.
🌐
CodePen
codepen.io › razitazi › pen › ONVMjp
Nested ordered list
Minimize HTML Editor · Fold All · Unfold All · <h1>Nested list</h1> <p>A nested ordered list with the use of <code>counter</code>.</p> <div class="snippet"> <ol> <li>A list item <ol> <li>A nested list item</li> <li>A nested list item</li> <li>A nested list item</li> </ol> </li> <li>A list item</li> <li>A list item</li> <li>A list item</li> <li>A list item</li> </ol> </div> !
🌐
W3Schools
w3schools.com › html › html_lists.asp
HTML Lists
Each list item starts with the <li> tag. The list items will be marked with bullets (small black circles) by default: <ul> <li>Coffee</li> <li>Tea</li> <li>Milk</li> </ul> ... An ordered list starts with the <ol> tag.
🌐
GeeksforGeeks
geeksforgeeks.org › html › what-is-nesting-of-list-how-to-create-the-nested-list-in-html
What is nesting of list & how to create the nested list in HTML ? - GeeksforGeeks
Nesting of lists in HTML involves placing one list within another list item, creating a hierarchical structure. This is done by embedding a <ul> (unordered) or <ol> (ordered) list inside an <li> (list item) element.
Published   July 23, 2025
🌐
Shiksha
shiksha.com › home › it & software › it & software articles › programming articles › html lists: ordered and unordered lists explained with examples
HTML Lists: Ordered and Unordered Lists Explained with Examples - Shiksha Online
October 13, 2024 - An HTML Nested list refers to a list within another list. We can create a nested ordered list, a nested unordered list, or a nested ordered list inside an unordered list.
🌐
SitePoint
sitepoint.com › html & css
Nested ordered lists with counters, driving me nuts! - HTML & CSS - SitePoint Forums | Web Development & Design Community
March 8, 2011 - Hi guys, First time poster here, so please be gentle. I am hoping one of you CSS gurus can help me out. I have been struggling with creating a nested ordered list, numbered correctly with decimals, using CSS 2.1 counters. To appear like so: [B]1. First Sentence 2. Second Sentence 2.1 Sub Sentence ...
Top answer
1 of 5
39

Here's an example which works in all browsers. The pure CSS approach works in the real browsers (i.e. everything but IE6/7) and the jQuery code is to cover the unsupported. It's in flavor of an SSCCE, you can just copy'n'paste'n'run it without changes.

<!doctype html>
<html lang="en">
    <head>
        <title>SO question 2729927</title>
        <script src="http://code.jquery.com/jquery-latest.min.js"></script>
        <script>
            $(document).ready(function() {
                if ($('ol:first').css('list-style-type') != 'none') { /* For IE6/7 only. */
                    $('ol ol').each(function(i, ol) {
                        ol = $(ol);
                        var level1 = ol.closest('li').index() + 1;
                        ol.children('li').each(function(i, li) {
                            li = $(li);
                            var level2 = level1 + '.' + (li.index() + 1);
                            li.prepend('<span>' + level2 + '</span>');
                        });
                    });
                }
            });
        </script>
        <style>
            html>/**/body ol { /* Won't be interpreted by IE6/7. */
                list-style-type: none;
                counter-reset: level1;
            }
            ol li:before {
                content: counter(level1) ". ";
                counter-increment: level1;
            }
            ol li ol {
                list-style-type: none;
                counter-reset: level2;
            }
            ol li ol li:before {
                content: counter(level1) "." counter(level2) " ";
                counter-increment: level2;
            }
            ol li span { /* For IE6/7. */
                margin: 0 5px 0 -25px;
            }
        </style>
    </head>
    <body>
        <ol>
            <li>first</li>
            <li>second
                <ol>
                    <li>second nested first element</li>
                    <li>second nested second element</li>
                    <li>second nested third element</li>
                </ol>
            </li>
            <li>third</li>
            <li>fourth</li>
        </ol>
    </body>
</html>
2 of 5
35

I know it is late to reply, but I just found an example of doing that using CSS. Add this to you CSS section (or file):

ol.nested
{
    counter-reset: item
}
li.nested
{
    display: block
}
li.nested:before
{
    content: counters(item, ".") ". ";
    counter-increment: item
}

Here is an example of how your list code would look like:

<ol class="nested">
<li class="nested">item 1</li>
<li class="nested">item 2
    <ol class="nested">
        <li class="nested">subitem 1</li>
        <li class="nested">subitem 2</li>
    </ol></li>
<li class="nested">item 3</li>
</ol>

HTH