The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other divs inside uls

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #32372

    As you know we can’t use divs inside uls. The only legal element inside ul is li. I’m in a situation that I have to use div inside my ul. The browser is fine with it, but is it bulletproof? Are there any reported problems with this?

    I’ve built a divider widget which will split the widgets in the sidebar into columns. So I have to wrap widgets inside divs and for most sidebars, it’s rendered as an unordered list.


    just change doctypes to html5: <!DOCTYPE html>
    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.

    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.


    whiteInkDesign is correct.

    It used to be bad, but as of html5 they changed that. So as long as you use the correct doctype, you should have any problems. At least not on any moderately modern browsers :-)

    Sometimes that is a valid concern though. But I’m lucky to live in Denmark where even IE6 seems to be a tale from the past. :-)


    It may wrap around two or three widgets. See this:
    And this is how it will be rendered:
    It works just fine, but I’m worried about browser compatibility and because this widget is supposed to go into the world wild web, it should work no matter what.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Other’ is closed to new topics and replies.