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 OverflowW3Schools
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 ...
Top answer 1 of 10
144
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>
2 of 10
84
Use this style to change only the nested lists:
ol {
counter-reset: item;
}
ol > li {
counter-increment: item;
}
ol ol > li {
display: block;
}
ol ol > li:before {
content: counters(item, ".") ". ";
margin-left: -20px;
}
Videos
07:07
HTML Nested Lists - YouTube
00:46
HTML-5 || NESTED ORDERED LIST || TUTORIAL. - YouTube
03:18
HTML Nested Unordered And Ordered List | HTML Course | Part 11 ...
14:44
Nested List in HTML | Multilevel List | Lists in HTML | Ordered ...
15:07
Ordered, Unordered, and Nested Lists - YouTube
06:15
#6 Nested Ordered list & Unordered list in HTML | Web Development ...
How do I create a nested list in HTML?
To create a nested list, place a
- or
- element of another list. Ensure to properly close all tags and structure your list to enhance readability and accessibility.
- element inside an
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!
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.
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>
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.
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
Top answer 1 of 3
31
<ol>
<li>One</li>
<li>Two
<ol>
<li>Inner One</li>
<li>inner Two</li>
</ol>
</li>
<li>Three</li>
</ol>
gives
- One
- Two
- Inner One
- inner Two
- Three
<ul> is for *u*nordered lists.
2 of 3
4
I think, you are searching for this:
<ol>
<li>One</li>
<li>Two
<ol>
<li>Inner One</li>
<li>inner Two</li>
</ol>
</li>
<li>Three</li>
</ol>
Outputs to:
1. One
2. Two
1. Inner One
2. Inner Two
3. Three
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.
Shay Howe
learn.shayhowe.com โบ html-css โบ creating-lists
Creating Lists - Learn to Code HTML & CSS
One trick with nesting lists is to know where to begin and end each list and list item. Speaking specifically about unordered and ordered lists, as that is where most nesting will occur, the only element that may reside directly within the <ul> and <ol> elements is the <li> element.
Top answer 1 of 11
2
The only valid child element of an ul is an li, so if you want to nest a ol inside of a ul it firsts has to be nested inside of an li
2 of 11
3
Here is the correct answer: remove one pair from the above post. You will get it. see message
below:
Well done! You're doing great!
- Shapes
- Colors
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 ...