-3

I am implementing the HTML of an image with a caption and I am not sure what the best idea is to build the markup for.

I am not sure if i should use a separate div with a class attached to it and then just add a

with the text.

<div class="caption">
      <p>Lorem ipsum...</p>
    </div>

over using only one html markup element that would also be able to solve the problem - but could lack in flexibility on the future.

<p class="caption">Lorem ipsum...</p>

Any ideas or suggestions from your side?

boehmatron
  • 713
  • 5
  • 15

1 Answers1

3

In HTML5 for images you can use figure and figcaption:

<figure>
    <img src='image.jpg' alt='image alt' />
    <figcaption>Caption goes here</figcaption>
</figure>
Torjescu Sergiu
  • 1,483
  • 10
  • 24