0% completed
In this lesson, you'll learn how to create nested (hierarchical) lists in HTML. Nested lists allow you to organize complex information by embedding lists within lists, enhancing the structure and readability of your web content.
HTML nested lists are lists that contain other lists within their items. This hierarchical structure is useful for displaying sub-items or categorizing information in a clear and organized manner. Both ordered (<ol>
) and unordered (<ul>
) lists can be nested to create multi-level lists.
The syntax for creating nested lists involves placing a new <ul>
or <ol>
inside an <li>
(list item) of an existing list. Here's the general structure:
<ul> <li>Parent Item 1 <ul> <li>Child Item 1</li> <li>Child Item 2</li> </ul> </li> <li>Parent Item 2</li> </ul>
Explanation:
<ul>
creates the main list.<li>
, another <ul>
creates a sublist containing "Child Item 1" and "Child Item 2".Let's explore two practical examples of creating nested lists in HTML.
This example demonstrates a basic nested unordered list, where each parent list item contains a sublist of related items.
Explanation:
<ul>
creates the main list of services.<li>
(e.g., "Graphic Design") contains a nested <ul>
with sub-services.In this example, we'll create a nested list that combines both ordered and unordered lists. This is useful when you want to display steps within categories or prioritize certain items.
Explanation:
<ol>
creates an ordered list representing the project phases.<li>
(e.g., "Planning"), a nested <ul>
lists specific tasks related to that phase.Understanding how to effectively use nested lists allows you to present information in a well-organized and professional manner, enhancing the overall user experience on your website.
.....
.....
.....