I am pretty new in WordPress development and I have the following doubt about how the sidebar are putted into a WordPress theme.

Looking into the official documentation: http://codex.wordpress.org/Function_Reference/dynamic_sidebar

I see some example, as:

<?php if ( is_active_sidebar( 'left-sidebar' ) ) : ?>
    <ul id="sidebar">
        <?php dynamic_sidebar( 'left-sidebar' ); ?>
<?php endif; ?>

Ok, my doubt is: why it put the dynamic_sidebar() call into an ul tag?

Why inside an ul tag and not into a standard container as a div? Are there a specific reason? What am I missing?


  • the 'why' is choice of the theme's author; this might possibly depend on which register_sidebar() parameters are used.
    – Michael
    Sep 12, 2014 at 18:10

1 Answer 1


Traditionally, sidebars were implemented as lists. Each sidebar "box" is an LI, so the sidebar as a whole would need to be inside a UL tag.

However, this is entirely a choice on the part of the theme author. The register_sidebar call can override the before_widget and after_widget parameters to be divs or anything else that the theme like, really. The default is list items (LI), because that's just the way themes are often implemented.

A list kind of makes sense, pre-HTML-5, because it's a bunch of widgets in boxes and the CSS to organize them is fairly easy and unlikely to conflict with other stuff on the page. Also, before we had things like section and article and aside, then putting divs inside other divs over and over repeatedly is unpleasant and weird.

In more modern HTML5 usage, one would be more likely to make the widgets into DIVs and to wrap them in an ASIDE area. It would be slightly more semantically correct.

There is no advantage or disadvantage to using UL's over DIV's. There may be a slight advantage to using ASIDE wrappers, as long as your document is structured properly.

  • Perfect explaination. now it it clear :-) Sep 13, 2014 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.