It should be quite obvious to you by now that the <li> tag defines an item in a list. It’s the universal tag for HTML list items in ordered (<ol>) and unordered (<ul>) lists, as we discuss above, and for directories (<dir>) and menus (<menu>), which we discuss in detail later in this chapter.
Because the end of a list element can always be inferred by the surrounding document structure, most authors omit the ending </li> tags for their list elements. That makes sense because it becomes easier to add, delete, and move elements around within a list. We recommend not using the </li> end tag.
Although universal in meaning, there are some differences and restrictions to the use of the <li> tag for each HTML list type. In unordered and ordered lists, what follows the <li> tag may be nearly anything, including other lists and multiple paragraphs. Typically, if it handles indentation at all, the browser successively indents nested list items, and the content in those items is justified to the innermost indented margin.
Directory and menu lists are another matter. They are lists of short items like a single word or simple text blurb and nothing else. Consequently, <li> items within <dir> and <menu> tags may not contain other lists or other block elements, including paragraphs, preformatted blocks, or forms.
Clean documents, fully compliant with the HTML standard, should not contain any text or other document item inside the unordered, ordered, directory, or menu lists that is not contained within an <li> tag. Most browsers are tolerant of violations to this rule, but then you can’t hold the browser responsible for compliant rendering for exceptional cases, either.














































