HTML Lists: Ordered, Unordered, and Description Lists

    HTML-Logo

    In HTML, we have three types of lists: ordered, unordered, and description lists. Each type of list is suitable for different scenarios and has its own specific tags.

    Unordered Lists

    Unordered lists are used when the list's order is not important. Unordered lists are created using the <ul> tag. Each item in the list is marked with a bullet point and is created using the <li> tag.

    Code Example:

        <ul>
            <li>Apple</li>
            <li>Banana</li>
            <li>Cherry</li>
        </ul>
    • Apple
    • Banana
    • Cherry

    Ordered Lists

    Ordered lists are used when the order of items is important. They are created using the <ol> tag, and like unordered lists, each item is marked using the <li> tag. By default, the list items are marked with numbers.

    Code Example:

        <ol>
            <li>First</li>
            <li>Second</li>
            <li>Third</li>
        </ol>
    1. First
    2. Second
    3. Third

    Description Lists

    Description lists are used to list terms alongside their descriptions. They are created using the <dl> tag. Each term is placed inside a <dt> tag and its corresponding description is placed inside a <dd> tag.

    Code Example:

        <dl>
            <dt>HTML</dt>
            <dd>Hyper Text Markup Language</dd>
            <dt>CSS</dt>
            <dd>Cascading Style Sheets</dd>
        </dl>

    Each type of list has its own use case and choosing the right type of list will make your HTML documents more semantic and easier to understand.