The W3 docs have a nested list example prefixed by DEPRECATED EXAMPLE:
, but they never corrected it with a non-deprecated example, nor explained exactly what is
Option 2 is correct: The nested
is a child of the it belongs in.
If you validate, option 1 comes up as an error in html 5 -- credit: user3272456
as child of
The proper way to make HTML nested list is with the nested
as a child of the to which it belongs. The nested list should be inside of the
element of the list in which it is nested.
- Parent/Item
- Child/Subitem
A list item can contain another entire list — this is known as "nesting" a list. It is useful for things like tables of contents, such as the one at the start of this article:
- Chapter One
- Section One
- Section Two
- Section Three
- Chapter Two
- Chapter Three
The key to nesting lists is to remember that the nested list should relate to one specific list item. To reflect that in the code, the nested list is contained inside that list item. The code for the list above looks something like this:
- Chapter One
- Section One
- Section Two
- Section Three
- Chapter Two
- Chapter Three
Note how the nested list starts after the and the text of the containing list item (“Chapter One”); then ends before the
of the containing list item. Nested lists often form the basis for website navigation menus, as they are a good way to define the hierarchical structure of the website.
Theoretically you can nest as many lists as you like, although in practice it can become confusing to nest lists too deeply. For very large lists, you may be better off splitting the content up into several lists with headings instead, or even splitting it up into separate pages.