<li> without parent labels?

Can I use <li> tags without parent tags?

i.e.

 <li> some copy 

or it should be ..

 <ul> (substitute your favorite list type) <li> some copy </ul> 

Related links:

+4
source share
7 answers

If by OK you mean "right, follow the standards and will check," then no . In the specification, only OL and UL may contain LI. (MENU and DIR are out of date)

If by OK you mean "will do," then yes.

In addition, to be β€œOK” by the first definition, you must also close the LI tags. Each tag must either be self-closing ( /> ) or have a corresponding closing tag. Here is a short and simple explanation of the correct XHTML (and, frankly, good HTML should also match these. There is no reason not to.)

+20
source

The correct HTML (not to mention strict XHTML) should be:

 <ul> <li>whatever</li> </ul> 
+6
source

No, using the li element without the ul or ol parent is not valid.

+3
source

No, this will definitely be invalid (X) HTML. I mean, you could, and the browser could do it right if you are lucky (IE, in particular, since it tends to be especially bland), but are far from any guarantees. You should always enclose <li> tags in either <ul> (unordered list) or <ol> (ordered list). Why don't you want anyway?

+3
source

No, although it may work in some browsers, this is invalid HTML.

+1
source

I checked the code verification below on the W3C Markup Verification Service :

 <li>item 1</li> <li>item 2</li> 

and the result:

the document type does not allow the "LI" element here; missing one of "UL", "OL", "DIR", the start tag is "MENU"

+1
source

li = list item, if it is without parents, where is the list?

http://www.w3schools.com/TAGS/tag_li.asp

http://www.w3.org/TR/html401/struct/lists.html

0
source

All Articles