Back to Freecodecamp

Step 26

curriculum/challenges/english/blocks/workshop-cat-photo-app/5dfb6a35eacea3f48c6300b4.md

latest2.7 KB
Original Source

--description--

A figure caption (figcaption) element is used to add a caption to describe the image contained within the figure element.

Here is an example of a figcaption element with the caption of A cute cat:

html
<figure>
  
  <figcaption>A cute cat</figcaption>
</figure>

After the image nested in the figure element, add a figcaption element with text set to:

Cats love lasagna.

--hints--

Your figcaption element should have an opening tag. Opening tags have the following syntax: <elementName>.

js
assert.exists(document.querySelector('figcaption'));

Your figcaption element should have a closing tag. Closing tags have a / just after the < character.

js
assert.match(code, /<\/figcaption\>/);

The figcaption element should be nested in the figure element.

js
assert.exists(document.querySelector('figure > figcaption'));

The lasagna img element should be nested in the figure element.

js
assert.exists(document.querySelector('figure > img'))
assert.equal(
    document.querySelector('figure > img')?.getAttribute('src').toLowerCase(),
      'https://cdn.freecodecamp.org/curriculum/cat-photo-app/lasagna.jpg'
);

The figcaption element nested in the figure element should be below the img element. You have them in the wrong order.

js
assert.equal(
  document.querySelector('figcaption')?.previousElementSibling.nodeName, 'IMG'
);

Your figcaption element's text should be Cats love lasagna. You have either omitted the text or have a typo.

js
assert.match(
  document.querySelector('figcaption')?.innerText?.trim(), /Cats love lasagna.?$/i
);

--seed--

--seed-contents--

html
<html>
  <body>
    <main>
      <h1>CatPhotoApp</h1>
      <section>
        <h2>Cat Photos</h2>
        <p>Everyone loves <a href="https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg">cute cats</a> online!</p>
        <p>See more <a target="_blank" href="https://freecatphotoapp.com">cat photos</a> in our gallery.</p>
        <a href="https://freecatphotoapp.com"></a>
      </section>
      <section>
        <h2>Cat Lists</h2>
        <h3>Things cats love:</h3>
        <ul>
          <li>catnip</li>
          <li>laser pointers</li>
          <li>lasagna</li>
        </ul>
        <figure>
          
--fcc-editable-region--
          
--fcc-editable-region--          
        </figure>
      </section>
    </main>
  </body>
</html>