Search code examples
htmlvalidationnestedsyntax-error

the validator shows this error when i try to make "ul" as a child of "ol" Or vice versa


i tried to check my code in a validator and it shows this message the code:

<ol>
  <li>learn html. </li>
  <li>learn css. </li>
  <li>learn python. </li>
  <li>save the world. </li>
  <ul>
    <li>be patient.</li>
    <li>improve your skills</li>
  </ul>

the error message:

"Element ol not allowed as child of element ul in this context. (Suppressing further errors from this subtree.) "

I understand what does it mean but i dont know why it doesnt allowed and how i write it without errors

I tried to allign the nesting well and didnt work ,i am a beginner in coding by the way.


Solution

  • The inner <ul> or <ol> must be a child of a <li>: Try this:

    <ol>
      <li>learn html. </li>
      <li>learn css. </li>
      <li>learn python. </li>
      <li>save the world. </li>
      <li>
        <ul>
          <li>be patient.</li>
          <li>improve your skills</li>
        </ul>
      </li>
    </ol>