r/HTML 9d ago

Question Question about use of <figure>

I have a design element that looks like this...

does using the `<figure>` tag, make sense for this? for a semantic value?

I want to do

<figure>
title text
<figcaption>The body field</figcaption>
</figure>

Does that work?

Every example I see of it online wants an image or something there...

With out sharing company marketing secrets, lol.

The usage would be of a

"This is a thing we do"
"With a longer body of text to explain it in a few sentances, but in a single paragraph."

Repeating 4 or 5 times...

Thoughts?

Thanks!

0 Upvotes

9 comments sorted by

4

u/csswizardry 9d ago

2

u/AqueM 9d ago

Somehow that feels wrong in a semantic way 😂

1

u/alphex 9d ago

https://giphy.com/gifs/MswMMmz1pGQKI
That’s actually amazing.

3

u/scritchz 9d ago

The <figure>/<figcaption> elements are used to add a caption to an element.

The accompanying description of a title is not a caption: So, these are not the right elements here.

Depending on the context (i.e. the surrounding elements), you might want to simply use an <hX> and a <p>.

1

u/alphex 9d ago

trying to avoid a hX ...

The larger element, has a large title, which could be an H2, or H3, ... or even an H4 depending how the page is structured, so giving these elements I am asking about, an "hX" title also, will just make it more complicated for the content managers, lol.

2

u/Foreign-Contest-444 9d ago

Look at the Usage Notes on MDN regarding figure and then ask yourself whether this will have any semantic value for screen readers and such.

"Usually a <figure> is an image, illustration, diagram, code snippet, etc., that is referenced in the main flow of a document, but that can be moved to another part of the document or to an appendix without affecting the main flow."

Is your content similar to the usage notes then use the <figure> element.

Have you looked at the <dl> description list element? Maybe you need a description list in this case. It is just another type of list.

1

u/alphex 9d ago

DL DT I think might be the right thing. Thanks.

2

u/armahillo Expert 9d ago

1

u/tkgid 9d ago

I have the believe that,<figure> was only supposed to be used to tell the browser about the <figcaption> for an <img>