<figure>: The "figure" element with optional caption

The HTML <figure> element represents self-contained content, potentially with an optional caption, that is specified using the <figcaption> element. The figure, its caption, and its contents are shown as a single unit.

Usage notes

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

Being a "sectioning root" , the content profile of the <figure> element is excluded from the main profile of the document.

A caption can be associated with the <figure> element by placing a caption within it with <figcaption> (as the first or last child). The first element <figcaption> found in the figure is presented as the figure caption.

Examples

Images

<!-- Solo un'immagine -->
<figure>
  <img
  src="immagine.png"
  alt="Descrizione dell'immagine">
</figure>

<!-- Immagine con una didascalia -->
<figure>
  <img
  src="immagine.png"
  alt="Descrizione dell'immagine">
  <figcaption>Didascalia a caso </figcaption>
</figure>

Code snippets

<figure>
  <figcaption>Ottieni i dettagli del browser utilizzando <code>navigator </code>.
  </figcaption>
  <pre>
  function NavigatorExample() {
    var txt;
    txt = "Browser CodeName: " + navigator.appCodeName + "; " ;
    txt+ = "Browser Name: " + navigator.appName + "; " ;
    txt+ = "Browser Version: " + navigator.appVersion + "; " ;
    txt+ = "Cookies Enabled: " + navigator.cookieEnabled + "; " ;
    txt+ = "User-agent header: " + navigator.userAgent + "; " ;
    console.log("NavigatorExample", txt);
  }
  </pre>
</figure>

Quotes

<figure>
  <figcaption><cite>Edsger Dijkstra:</cite></figcaption>
  <blockquote>Se il debug è il processo di rimozione dei bug del software,
  allora la programmazione deve essere il processo di inserimento.</blockquote>
</figure>

Poems

<figure>
  <p style="white-space: pre">
  Bid me discourse, I will enchant thine ear,
  Or like a fairy trip upon the green,
Or, like a nymph, with long dishevelled hair,
  Dance on the sands, and yet no footing seen:
Love is a spirit all compact of fire,
  Not gross to sink, but light, and will aspire. </p>
  <figcaption><cite>Venus and Adonis</cite>,
  by William Shakespeare</figcaption>
</figure>