Skip to content

Incorrect html5 figure breaks css #1005

Description

@teepeemm

Continuing my adventures with the caption package, the following tex

\documentclass{article}
\usepackage{caption}

\begin{document}

\begin{center}
\marginpar{\captionsetup{type=figure}\caption{good caption}}
\end{center}

\begin{center}
text
\marginpar{\captionsetup{type=figure}\caption{bad caption}}
\end{center}

\end{document}

produces html I would expect, but that turns out to be incorrect. A simplified version of that html is the following:

<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>Test</title>
<style type="text/css">
span figure { border: 1px solid green; }
body > figure { border: 1px solid red; }
</style>
</head>
<body>
<span><figure>good content</figure></span>
<p><span><figure>bad content</figure></span></p>
</body>
</html>

The problem is that it seems figure tags aren't allowed in p tags (a severely out of date source). Therefore, Chrome and Firefox (at least) treat the second figure as if it were

<p><span></span></p>
<figure>bad content</figure>
<p></p>

This means that the default css for margin notes no longer applies. (The W3C validator also complains about the first span > figure, but Chrome and Firefox at least render it correctly.)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions