Is an HTML list allowed to have no child list items? Specifically, is this allowed:
<ul>
</ul>
The HTML validator on the W3C site does not complain when you test it with an empty list, e.g.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test with empty list</title>
</head>
<body>
<ul>
</ul>
</body>
</html>
So semantically, it's not illegal from a pure HTML perspective. However, the WAI-ARIA Recommendation section on Required Owned Elements suggests that lists must have at least one listitem:
For example, an element with the role list will own at least one element with the role group or listitem.
However, the WCAG 2 test rule for this very check suggests that the rule is inapplicable, because it does not have explicit role:
**Inapplicable Example 2**
This ul element does not have an explicit semantic role.
<ul>
<li>Item 1</li>
</ul>
One automated accessibility testing tool (SiteImprove) is throwing an error for an empty element, whereas other tools (Lighthouse, WAVE) are not.
I'm trying to get a definite answer on whether an empty list is legal or not.