[html5] Optional end tag for P before FIGURE?
Jukka K. Korpela
jukka.k.korpela at kolumbus.fi
Mon Oct 6 00:47:53 PDT 2014
2014-10-03 23:09, Ezequiel Garzón wrote:
> Greetings! Is there a reason FIGURE is not one of the elements before
> which the P end tag may be omitted? The WHATWG and W3C validators do
> not objetct, but it is not valid markup as I see it:
Probably this is just an oversight: FIGURE was added to the language
after this text was written:
> "A p element's end tag can be omitted if the p element is immediately
> followed by an address, article, aside, blockquote, div, dl, fieldset,
> footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, main, menu,
> nav, ol, p, pre, section, table, or ul, element, or if there is no
> more content in the parent element and the parent element is not an a
> element."
>
>
In previous versions of HTML, start or end tag omission rules were
either derivable
from formal syntax rules in a DTD or, in XHTML, start or end tag
omission was
completely forbidden (as it still is in XHTML syntax). Now that HTML
isn’t even
formally based on SGML, the tag omission rules need to be spelled out in
detail
as above. Changes in the language thus require revisions of such rules.
You can test what modern browsers actually do:
<!doctype html>
<style>
p { background: yellow }
</style>
<p>Hello world
<figure><img src=test.png alt="(demo)">
<figcaption>Just a demo</figcaption>
</figure>
Text continues here.
If the image and its caption are not indented, the browser does not
support the figure
element (in practice; in theory, it could support it but without
applying the "expected
rendering" rules, but that would be pointless). The yellow background
does not
extend to the figure or to the text after it, so the browser has implied
a closing
</p> when it sees <figure> and there is an open p element. You can check
this
also in the browser's Developer Tools, where elements are typically shown so
that the implied tags are present.
--
Yucca, http://www.cs.tut.fi/~jkorpela/
More information about the Help
mailing list