How to semantically provide a caption, title, or label for a list in HTML?

Spread the love

Sometimes, we want to semantically provide a caption, title, or label for a list in HTML.

In this article, we’ll look at how to semantically provide a caption, title, or label for a list in HTML.

How to semantically provide a caption, title, or label for a list in HTML?

To semantically provide a caption, title, or label for a list in HTML, we use the figcaption element.

For instance, we write

<figure>
  <figcaption>Fruit</figcaption>
  <ul>
    <li>Apple</li>
    <li>Pear</li>
    <li>Orange</li>
  </ul>
</figure>

to put the figcaption element with the caption in the figure element with the ul list.

Conclusion

To semantically provide a caption, title, or label for a list in HTML, we use the figcaption element.

Leave a Reply

Your email address will not be published. Required fields are marked *