The <div> element is not allowed inside <figure> in the HTML5 standard.
As with plain image, it's by default centered, slightly rounded and has a
border around the caption and description. The caption is expected to be in the
:html:`<figcaption>` element. The description is optional, but should be
-wrapped in some tag as well (for example a :html:`<div>`). The
+wrapped in some tag as well (for example a :html:`<span>`). The
:css:`.m-fullwidth` class works here too and you can also wrap the
:html:`<img>` element in an :html:`<a>` tag to make it clickable.
<figure class="m-figure">
<img src="ship.jpg" alt="Ship" />
<figcaption>A Ship</figcaption>
- <div>Photo © <a href="http://blog.mosra.cz/">The Author</a></div>
+ <span>Photo © <a href="http://blog.mosra.cz/">The Author</a></span>
</figure>
.. raw:: html
<figure class="m-figure">
<img src="{filename}/static/ship-small.jpg" alt="Ship" />
<figcaption>A Ship</figcaption>
- <div>Photo © <a href="http://blog.mosra.cz/">The Author</a></div>
+ <span>Photo © <a href="http://blog.mosra.cz/">The Author</a></span>
</figure>
`Image grid`_
specified otherwise
- Figures are using HTML5 :html:`<figure>` tag instead of
:html:`<div class="figure">`, figure caption is using HTML5 :html:`<figcaption>`
- instead of :html:`<p class="caption">`
+ instead of :html:`<p class="caption">` and figure legend is just a :html:`<span>`
+ as :html:`<div>` is not allowed inside :html:`<figure>`
- Drops *a lot of* useless classes from elements such as :html:`<div class="docutils">`
- Makes it possible to have :html:`<a>` elements with block contents (allowed
in HTML5)
self.section_level -= 1
self.body.append('</section>\n')
+ # Legend inside figure -- print as <span> (instead of <div class="legend">,
+ # as that's not valid inside HTML5 <figure> element)
+ def visit_legend(self, node):
+ self.body.append(self.starttag(node, 'span'))
+
+ def depart_legend(self, node):
+ self.body.append('</span>\n')
+
# Literal -- print as <code> (instead of some <span>)
def visit_literal(self, node):
self.body.append(self.starttag(node, 'code', ''))