Files
freeCodeCamp/curriculum/challenges/italian/01-responsive-web-design/basic-html-and-html5/nest-many-elements-within-a-single-div-element.md

4.0 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
bad87fee1348bd9aede08835 Nidificare diversi elementi all'interno di un singolo elemento div 0 https://scrimba.com/p/pVMPUv/cNW4kC3 18246 nest-many-elements-within-a-single-div-element

--description--

L'elemento div, noto anche come elemento di divisione, è un contenitore di uso generale per altri elementi.

L'elemento div è probabilmente l'elemento HTML usato più comunemente.

Proprio come qualsiasi altro elemento puoi aprire un elemento div con <div> e chiuderlo su un'altra linea con </div>.

--instructions--

Nidifica le tue liste "Things cats love" e "Top 3 things cats hate" all'interno di un singolo elemento div.

Suggerimento: Prova a mettere il tuo tag div di apertura sopra l'elemento p "Things cats love" e il tag div di chiusura dopo il tag ol in modo che entrambe le liste siano all'interno di un div.

--hints--

I tuoi elementi p dovrebbero essere annidati all'interno dell'elemento div.

assert($('div').children('p').length > 1);

Il tuo elemento ul dovrebbe essere annidato all'interno dell'elemento div.

assert($('div').children('ul').length > 0);

Il tuo elemento ol dovrebbe essere annidato all'interno dell'elemento div.

assert($('div').children('ol').length > 0);

Il tuo elemento div dovrebbe avere un tag di chiusura.

assert(
  code.match(/<\/div>/g) &&
    code.match(/<\/div>/g).length === code.match(/<div>/g).length
);

--seed--

--seed-contents--

<h2>CatPhotoApp</h2>
<main>
  <p>Click here to view more <a href="#">cat photos</a>.</p>

  <a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>

  <p>Things cats love:</p>
  <ul>
    <li>cat nip</li>
    <li>laser pointers</li>
    <li>lasagna</li>
  </ul>
  <p>Top 3 things cats hate:</p>
  <ol>
    <li>flea treatment</li>
    <li>thunder</li>
    <li>other cats</li>
  </ol>

  <form action="https://www.freecatphotoapp.com/submit-cat-photo">
    <label for="indoor"><input id="indoor" type="radio" name="indoor-outdoor" value="indoor" checked> Indoor</label>
    <label for="outdoor"><input id="outdoor" type="radio" name="indoor-outdoor" value="outdoor"> Outdoor</label><br>
    <label for="loving"><input id="loving" type="checkbox" name="personality" value="loving" checked> Loving</label>
    <label for="lazy"><input id="lazy" type="checkbox" name="personality" value="lazy"> Lazy</label>
    <label for="energetic"><input id="energetic" type="checkbox" name="personality" value="energetic"> Energetic</label><br>
    <input type="text" placeholder="cat photo URL" required>
    <button type="submit">Submit</button>
  </form>
</main>

--solutions--

<h2>CatPhotoApp</h2>
<main>
  <p>Click here to view more <a href="#">cat photos</a>.</p>

  <a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
  <div>
    <p>Things cats love:</p>
    <ul>
      <li>cat nip</li>
      <li>laser pointers</li>
      <li>lasagna</li>
    </ul>
    <p>Top 3 things cats hate:</p>
    <ol>
      <li>flea treatment</li>
      <li>thunder</li>
      <li>other cats</li>
    </ol>
  </div>
  <form action="https://www.freecatphotoapp.com/submit-cat-photo">
    <label for="indoor"><input id="indoor" type="radio" name="indoor-outdoor" value="indoor" checked> Indoor</label>
    <label for="outdoor"><input id="outdoor" type="radio" name="indoor-outdoor" value="outdoor"> Outdoor</label><br>
    <label for="loving"><input id="loving" type="checkbox" name="personality" value="loving" checked> Loving</label>
    <label for="lazy"><input id="lazy" type="checkbox" name="personality" value="lazy"> Lazy</label>
    <label for="energetic"><input id="energetic" type="checkbox" name="personality" value="energetic"> Energetic</label><br>
    <input type="text" placeholder="cat photo URL" required>
    <button type="submit">Submit</button>
  </form>
</main>