To create html nested lists, place a complete <ul> or <ol> inside an <li> of the parent list. The inner list must be a child of a list item, never a direct child of the outer list, and browsers indent it and change the bullet style for each level.
Nested lists let you show hierarchy, such as a menu with sub-menus, an outline with sub-points or a to-do list with sub-tasks.
The inner list goes inside the <li> that it belongs to, usually after that item's own text.
By default the first level uses filled discs, the second level uses hollow circles and the third level uses squares. The inner list is indented by the browser's default left padding.
Many beginners place the inner list straight inside the outer <ul>, next to the <li> elements. This is invalid HTML, even if some browsers render it acceptably.
The valid version tells browsers and assistive technology that Apple belongs to Fruits. In the invalid version, the relationship is missing, so a screen reader may not announce the hierarchy correctly.
You can combine list types at any level. A numbered procedure with bulleted notes is a typical case.
The inner ordered list restarts at its own first number, so each level counts independently.
Sub-menus are a practical use of nesting. Put the sub-list inside the parent's <li>, together with the link.
With CSS you can hide the inner list and show it when the parent is hovered or focused. Make sure keyboard users can open sub-menus too, for example with :focus-within:
Use the child combinator to style each level separately, and use list-style-type to change the bullet at a specific depth.
Keep nesting shallow. Three levels is usually the limit before a list becomes hard to read; deeper hierarchies are better shown as separate sections with headings.
When the hierarchy comes from data, build the nested lists with a small recursive function. Each child list is appended to the parent <li>, which keeps the markup valid.
The function calls itself for every level, so it works for any depth. Using textContent also avoids inserting untrusted text as HTML.
Screen readers announce each list and its depth, for example "list, 2 items, nested level 2". That helps listeners only when the markup is correct, which is why the inner list must live inside an li. For menus, give the top nav an aria-label and make sure every sub-menu can be reached with the keyboard.
<ul> directly inside another <ul>?No. The nested list must be inside an <li>. Direct children of a list may only be li elements (and script-supporting elements).
HTML sets no hard limit, but more than three levels harms readability and accessibility. Restructure the content if you need more.
Yes. An inner <ol> begins at 1 unless you set start, and it counts separately from the outer list.
<li>?Yes. An li accepts flow content, so paragraphs, tables, images and other lists are allowed.
Nest a list by placing the inner <ul> or <ol> inside the parent <li>, never directly in the parent list. You can mix ordered and unordered lists, style each level with CSS, and use nesting for outlines and sub-menus. Keep it to about three levels so the structure stays clear for every reader.