freeCodeCamp/curriculum/challenges/italian/14-responsive-web-design-22/learn-html-by-building-a-ca.../5ef9b03c81a63668521804d8.md

3.1 KiB

id title challengeType dashedName
5ef9b03c81a63668521804d8 Step 36 0 step-36

--description--

L'elemento input ti permette di raccogliere dati da un modulo web in vari modi. Come gli elementi img, gli elementi input sono self-closing e non necessitano di tag di chiusura.

Annida un elemento input nell'elemento form.

--hints--

L'elemento form dovrebbe avere un tag di apertura e di chiusura nell'ordine corretto. Potrebbero mancare uno o entrambi i tag richiesti, o essere nell'ordine sbagliato.

const noSpaces = code.replace(/\s/g, '');
assert(
  document.querySelector('form') &&
    code.match(/<\/form>/g) &&
    noSpaces.indexOf('<form') < noSpaces.indexOf('</form>')
);

Il tag di apertura dell'elemento form dovrebbe avere solo un attributo action. Rimuovi qualsiasi altra cosa dal suo interno.

assert([...document.querySelector('form').attributes].length < 2);

Dovresti creare un elemento input. Controlla la sintassi.

assert(document.querySelector('input'));

L'elemento input dovrebbe avere un tag di apertura, ma non un tag di chiusura.

assert(document.querySelector('input') && !code.match(/<\/input\>/g));

L'elemento input dovrebbe essere annidato all'interno dell'elemento form.

assert(document.querySelector('form > input'));

L'elemento form dovrebbe contenere solo l'elemento input. Rimuovi qualsiasi elemento HTML o testo tra i tag dell'elemento form.

assert(
  $('form')[0].children.length === 1 &&
    $('form')[0].innerText.trim().length === 0
);

--seed--

--seed-contents--

<html>
  <body>
    <h1>CatPhotoApp</h1>
    <main>
      <section>
        <h2>Cat Photos</h2>
        <!-- TODO: Add link to cat photos -->
        <p>Click here to view more <a target="_blank" href="https://freecatphotoapp.com">cat photos</a>.</p>
        <a href="https://freecatphotoapp.com"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
      </section>
      <section>
        <h2>Cat Lists</h2>
        <h3>Things cats love:</h3>
        <ul>
          <li>cat nip</li>
          <li>laser pointers</li>
          <li>lasagna</li>
        </ul>
        <figure>
          <img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/lasagna.jpg" alt="A slice of lasagna on a plate.">
          <figcaption>Cats <em>love</em> lasagna.</figcaption>  
        </figure>
        <h3>Top 3 things cats hate:</h3>
        <ol>
          <li>flea treatment</li>
          <li>thunder</li>
          <li>other cats</li>
        </ol>
        <figure>
          <img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/cats.jpg" alt="Five cats looking around a field.">
          <figcaption>Cats <strong>hate</strong> other cats.</figcaption>  
        </figure>
      </section>
      <section>
        <h2>Cat Form</h2>
--fcc-editable-region--
        <form action="https://freecatphotoapp.com/submit-cat-photo">
        </form>
--fcc-editable-region--
      </section>
    </main>
  </body>
</html>