Yes you can use class in figure
figure {
float: right;
width: 30%;
text-align: center;
font-style: italic;
font-size: smaller;
text-indent: 0;
border: thin silver solid;
margin: 0.5em;
padding: 0.5em;
}
<figure>
<p><img src="https://www.w3.org/Style/Examples/007/eiffel.jpg"
width="136" height="200"
alt="Torre Eiffel">
<figcaption>Miniatura da
torre Eiffel no
Parque Mini-France</figcaption>
</figure>
figure {
float: right;
width: 30%;
text-align: center;
font-style: italic;
font-size: smaller;
text-indent: 0;
border: thin silver solid;
margin: 0.5em;
padding: 0.5em;
}
<figure>
<img src="https://www.w3.org/Style/Examples/007/eiffel.jpg"
width="136" height="200"
alt="Torre Eiffel">
<figcaption>Miniatura da
torre Eiffel no
Parque Mini-France</figcaption>
</figure>
NOTE: The figcaption element used to mark a caption for inserted contents using the element <figure>
. Always must come between the element <figure>
, that is to say, the child element of the <figure>
. The tag <figcaption>
is valid only among the <figure>
.
since in the commentary was addressed the need for the p tag ...
It is worth noting that the element <figure>
and <figcaption>
not only for images and photos, but also for diagrams, graphs, texts (such as poems, source code, citations, etc.), an excerpt of code - with html tags - ex: <p>
.
Mozilla Developer Network
HTML Global Attributes
Learn more
What is the need to use <p> inside the figure?
– Gladison
see the two executes , one with tag p and the second without tag p
– user60252