0 2 Votes

HTML Validation: UL in UL causes error "ul not allowed as child of element ul in this context"

Question by Guest | 03/06/2014 at 12:01

Recently, I had a look at my website in an HTML Validator. I got the following error message there:

Error: ul not allowed as child of element ul in this context. (Suppressing further errors from this subtree.)

The error refers to one of my ul-lists in which I have included another nested ul-list as a sub list. It is something like this:

<ul>
  <li>A</li>
  <ul>
    <li>A1</li>
    <li>A2</li>
  </ul>
  <li>B</li>
  <li>C</li>
</ul>

Now, I wonder whether it is possible at all to create such a construction using valid HTML. As I understand of this error, this is not allowed to use an UL element as a child of another UL. Or is there any possibility to do so?

ReplyPositiveNegative

Stefan Trost

Show Profile | Message
Avatar
4Best Answer
6 Votes

Sure it is possible to create nested lists with valid HTML.

You only have to note that there should always and only be LI elements directly under UL elements. So, also your sublist has to be declared as list element surrounded by <li></li> like that:

<ul>
  <li>A</li>
  <li>
      <ul>
         <li>A1</li>
         <li>A2</li>
      </ul>
  </li>
  <li>B</li>
  <li>C</li>
</ul>

With this, the HTML Validator should not complain.
03/06/2014 at 21:51

ReplyPositive Negative
Reply

Related Topics

"G" or "E" sign on my mobile
Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own articles on askingbox.com. How to do.