59

I'm having this code:

<ul>
   <div>
   </div>
</ul>

I feel no issue in my browser rendering it. I have read this too somewhere that li should only be used as direct child of ul.

Is this correct? Can't I use div as a direct child of UL? Is there any documentation for the above confusion?

Edit: This link says I can http://css-tricks.com/forums/discussion/11593/divs-inside-uls/p1

HDJEMAI
  • 9,436
  • 46
  • 67
  • 93
Rocky Singh
  • 15,128
  • 29
  • 99
  • 146
  • 1
    You should put your div tag inside an li tag – Undefined Aug 01 '12 at 08:44
  • 2
    Regarding your edit: that link says you can't. –  Aug 01 '12 at 08:47
  • "div's inside ul's are totally legit in html5 and you won't be hurting anything, its honestly that easy. You can even wrap block elements in anchor tags, its craaaaazzzy awesome." I found this comment there. – Rocky Singh Aug 01 '12 at 08:51
  • 4
    @RockySingh From that same post: "edit: I jumped the gun with my endorsement, a div directly inside a ul is incorrect, but a div inside an li is completely valid. Thank wolfcry for clarification." –  Aug 01 '12 at 08:51
  • What you have to consider here is why you would want to do that. If the piece of content is a list item, put it in an `
  • ` and let CSS handle how you want it; if it's not a list item, what is it doing in a list? Should it possibly come after or before the list?
  • – anotherdave Aug 01 '12 at 08:56