HTML - Is it semantically correct to use multiple <p> tags and nest <ul> inside <li></li>?

71 Views Asked by At

I need to code the following text in HTML:

  1. Data:

    We collect...

    • a
    • b
  2. Aditional data:

    We collect...

    • c
    • d

Is it correct to do the following in html?

<ul>
  <li>
    <p>Data:</p>
    <p>We collect...</p>
    <ul>
      <li>a</li>
      <li>b</li>
    </ul>
  </li>

  <li>
    ...
  </li>
</ul>
1

There are 1 best solutions below

0
Sean On

It's valid HTML, but without knowing more about your content, it's hard to determine if it's semantically correct. It seems like it may be more correct in this instance to use sections with headings instead:

<section>
  <h2>Data</h2>
  <p>We collect...</p>
  <ul>
    <li>a</li>
    <li>b</li>
  </ul>
</section>
<section>
  <h2>Additional Data</h2>
  <p>We collect...</p>
  <ul>
    <li>c</li>
    <li>d</li>
  </ul>
</section>