How to fix: Document type does not allow element "li" here; missing one of "ul", "ol", "menu", "dir" start tag

Most Likely Cause and Fix

Your markup contains a <li> element in a place it does not belong.

The validator is telling you that the <li> must be inside a <ul>, <ol>, <menu> or <dir> element.

What This Error Means

HTML is often comprised of elements nested inside other elements, such as the placing of an anchor within a paragraph:

    Hello <a href="">World!</a>

There are rules regarding which elements can be nested inside other elements and when this is allowed to happen.

Most notably, block-level elements, such as <div>, are not allowed inside inline elements such as <span>.

This error relates to the when and is telling you that the <li> element on the relevant line number is not allowed unless inside a <ul>, <ol>, <menu> or <dir> element.

How To Fix It

The specific error message you encountered will refer to a line and column number. This will guide you to the exact point in your markup to which the error relates.

Find the <li> element in question and check to see what element it is inside of.

With respect to the specific portion of the document referred to by the given line and column number, the troublesome <li> must be within a <ul>, <ol>, <menu> or <dir> element.

Check that you haven't closed a <ul>, <ol>, <menu> or <dir> element too soon and make sure that the <li> is inside a <ul>, <ol>, <menu> or <dir> element as expected.

Discuss, Comment and Improve

Did this help you? Can this page be improved? Let us know!

comments powered by Disqus