brain storm
brain storm

Reputation: 31252

Can not have an ul inside an ol in html

I get the following validation error when I tested my HTML.

Please look at the attached image for the HTML code. enter image description here "Element ul not allowed as child of element olin this context."

Upvotes: 0

Views: 14213

Answers (4)

imq
imq

Reputation: 11

Try to wrap <ul> part into a <li> tag.

Upvotes: 1

Explosion Pills
Explosion Pills

Reputation: 191749

This is because the content model for <ol> (and <ul> actually) is zero or more li elements

These two tags actually can't contain anything other than <li> tags or nothing at all. If you have <ol><ul> browsers will automatically close the <ol> tag before beginning the <ul> (well, the good ones).

I think your intent is to have:

<ol>
    <li>
        <ul>

The <ul> can be contained inside of an <li> that is a child of the <ol>.

Upvotes: 9

pokka
pokka

Reputation: 31

You should do these

<ol>
  ...
  <li>title</li>
  <li><!-- add this -->
    <ul><!-- your ul put here -->
    ...
    </ul>
  </li><!-- add this -->
  ...
</ol>

PS. In some case use original code better than image.

Upvotes: 1

Mimo
Mimo

Reputation: 6075

This is because you should wrap the internal <ul> in a list <li> item:

<ul><li>text</li>....</ul>

becomes:

<li><ul><li>text</li>....</ul></li>

Upvotes: 4

Related Questions