Skip to content
WordPressRule: listitem•Reviewed Oct 2026

Wrap all li elements inside parent ul or ol containers in WordPress

Every `<li>` element must be directly contained within a parent `<ul>` or `<ol>`.

What's wrong

Orphaned `<li>` elements outside of list tags violate HTML grammar and break accessibility semantics.

Who it affects

Screen readers cannot announce 'List of X items' or announce the position of the item in the list.

How to fix on WordPress

Wrap dynamic post lists and block query loops in proper `<ul>` containers.

Code example

Problematic Code
PHP
<?php while ( have_posts() ) : the_post(); ?>
  <li><?php the_title(); ?></li>
<?php endwhile; ?>
Recommended Accessible Code
PHP
<ul class="post-list">
  <?php while ( have_posts() ) : the_post(); ?>
    <li><?php the_title(); ?></li>
  <?php endwhile; ?>
</ul>

How to check your fix

Inspect each `<li>` element in DevTools and confirm its immediate parent is `<ul>` or `<ol>`.

Check if your site has this issue

Scan any public store page free against WCAG 2.2 AA in 30 seconds.

Your session has ended

Sign in again to carry on. Anything you typed on this page is kept.

Signed in another way? Use another method (opens a new tab)