Does the <li> tag always have to be nested within the <ul> tag?



Does the <li> tag always have to be nested within the <ul> tag?


The <li> element can be a direct child of either the <ul> or the <ol> elements but it should never exist outside of either of these parent elements.

FAQ: Learn HTML Elements - Intro to HTML - Unordered Lists


  • tag will be placed inside the
      tag because the
    • tag mean listed items and that helps you organize your unlisted items.
    • help organize all of the items after the unlisted items.

  • #3

    what is an <ol> element?


    SInce ‘ul’ is unorganised list, ‘ol’ must be organised list IMO.


    ul stands for “Unordered List” and ol stands for " Ordered Lists" except that each list item is numbered.
    while li element will show the lists like this:

    • List item 1
    • List item 2
    • List item 3

    A ol element will show the lists like this:

    1. List item 1
    2. List item 2
    3. List item 3


    The Living Standard also includes the <menu></menu> element, which also has LI as direct children.

    By default they are numbered from 1 to n, but we can also specify letters, lower or upper case, or Roman numerals, also upper or lower case. We can also specify the starting character.

    Scroll down that page to find UL, LI, and MENU.


    I notice that I can leave aside the end tag for list items () and everything seems to work fine. Is it really necessary to type an end tag for list items?


    Best practices recommend including both tags; however, W3C has gone along with omitting the endtag. This also applies to paragraphs. Let the situation dictate, and keep it localized and well contained.