Loading...
Loading...

HTML Unordered and Ordered Lists Tutorial

HTML provides list tags to create unordered (bulleted) and ordered (numbered) lists. Lists are useful for organizing content in a structured format.

1. Unordered Lists

Unordered lists are created using the <ul> tag, with list items defined inside it using <li> tags. By default, items are displayed with bullet points.


<ul>
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
</ul>
                    

This example creates a simple bulleted list with three items.

Preview:
  • Item 1
  • Item 2
  • Item 3

2. Ordered Lists

Ordered lists are created using the <ol> tag, with list items specified using <li> tags. By default, items are displayed with numbers.


<ol>
    <li>Step 1</li>
    <li>Step 2</li>
    <li>Step 3</li>
</ol>
                    

This example creates a numbered list with three steps.

Preview:

1. Step 1
2. Step 2
3. Step 3

3. Nested Lists

HTML allows you to nest lists, creating lists within lists for complex structures:


<ul>
    <li>Item 1
        <ul>
            <li>Subitem 1.1</li>
            <li>Subitem 1.2</li>
        </ul>
    </li>
    <li>Item 2</li>
</ul>
                    

This nested list example creates subitems under "Item 1" in the main list.

Preview:
  • Item 1
    • Subitem 1.1
    • Subitem 1.2
  • Item 2

4. Changing List Styles with CSS

You can customize the appearance of lists with CSS, such as changing bullet styles and numbering types:


ul {
    list-style-type: square;
}
ol {
    list-style-type: upper-roman;
}
                    

This example changes unordered list bullets to squares and ordered list numbers to Roman numerals.

Preview: This is a customized ordered and unordered list:
  • List style type square
  1. List style type upper-roman

5. Conclusion

HTML lists are powerful for organizing content. Unordered and ordered lists provide structure and visual hierarchy, making information easier to read and navigate.

0 Interaction
661 Views
Views
37 Likes
×
×
🍪 CookieConsent@Ptutorials:~

Welcome to Ptutorials

Note: We aim to make learning easier by sharing top-quality tutorials.

We kindly ask that you refrain from posting interactions unrelated to web development, such as political, sports, or other non-web-related content. Please be respectful and interact with other members in a friendly manner. By participating in discussions and providing valuable answers, you can earn points and level up your profile.

$ Allow cookies on this site ? (y/n)

top-home