In HTML5 we currently have a <figure>
element, defined like so (W3C reference)
The figure element represents a unit of content, optionally with a caption, that is self-contained, that is typically referenced as a single unit from the main flow of the document, and that can be moved away from the main flow of the document without affecting the document’s meaning.
Recently a new element <picture>
was proposed by the Responsive Images Community group and it was defined in the reference like so
The picture element used for displaying an image that can come from a range of sources (see srcset attribute). Which image the user agent displays depends on the algorithm for deriving the source image.
Since the two descriptions seems to be not contradictory (and documentation on picture is on draft state yet) here my question: is it possible (technically and semantically) to have a nested picture
inside a figure
element, in this way?
<figure> <picture> <source ...> <source ...> <source ...> <img..> </picture> <figcaption>...</figcaption> </figure>
I've found no references about it in specs. :\
Note: I'm aware that no browser implements currently this element, I'm just making some experiments with jQuery picture
Thank you.
The HTML <picture> element gives web developers more flexibility in specifying image resources. The <picture> element contains one or more <source> elements, each referring to different images through the srcset attribute. This way the browser can choose the image that best fits the current view and/or device.
The <figure> tag in HTML is used to add self-contained content like illustrations, diagrams, photos, or codes listing in a document.
1. The figure tag is used to semantically organize the content of images, videos, audios or even charts or tables, block of codes in the HTML document. The image tag is used to add an image to an HTML page.
Multiple Images in figureYou can put multiple img tags in a figure if they are related in the context of your document.
Mat Marquis here—I’m one of the editors on the picture
spec ( http://picture.responsiveimages.org ).
The short answer is “yes,” the long answer is “definitely.” Semantically correct (figure
can contain images, charts, tables, code snippets, and so on), and 100% valid.
You won't find it since it's not actually official yet, but I am going to assume the answer is yes, that is fine.
At the moment, you do something like:
<figure> <img src="image.jpg" alt="The Image"> <figcaption>A Caption</figcaption> </figure>
and <picture>
is simply meant to be the a method of have a multiple src'd <img>
for responsive sites, so technically it would seem like -- if it were approved -- your example is valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With