A (terrible?) way to do footnotes in HTML
shkspr.mobi
shkspr.mobi
And since they are basic links, they work in a PDF and of course on a web page without any extra work on your part. Jumping isn't that great (and endnotes should always have a jumpback link) but it's not a bad baseline impl.
I think following the endnote + noteref epub spec is the way to go.
How they actually get rendered, like putting them inline, is then a trivial concern for the reader software.
I personally like the modal overlay approach that some readers do. It handles endnotes of unlimited length and lets them be arbitrarily complicated since the modal is basically just an inset page. For example, a downside of inline footnotes is what should be done when they are too long to fit on the remainder of the page? Do you scroll next-page until you finish reading it, then prev-page back to where you started? etc. Either way, seems ideal to leave that concern to the reader software.
See https://html.spec.whatwg.org/#the-p-element and https://html.spec.whatwg.org/#phrasing-content.
Rather, it would be incorrect for rendering engines to not close the paragraph at this point.
(HTML parsing is defined exhaustively. If two browsers parse a given input string to a different DOM tree, at least one of them is buggy.)
But the point is moot: XHTML is completely dead, lacks newer HTML elements like <details>, and no browser includes an XHTML parser anyway—they’ll use the HTML parser.
Here's simple test.xhtml:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="UTF-8"/>
<title>XHTML</title>
</head>
<body>
<p>
<details>
<summary>Summary</summary>
Details
</details>
</p>
</body>
</html>
It's rendered properly in Chrome. If some XML is wrong, it'll error. So at least Chrome supports XHTML with strict XML validator. And <detail> tag works as expected and it's even nested inside <p> tag in DOM.That XHTML won't pass validator.w3.org (<details> can't be inside <p>), but Chrome does not care.
I believe browsers would be quite within their rights to do DTD validation and consequently reject such a document as this, but they don’t actually do so. (Even if the DTD is specified correctly for XHTML 1.0 Strict, nothing changes.)
Thanks for correcting me. I have updated my mental knowledge repository.
Browsers were always non-validating XML processors. Maybe you're thinking about the Well-formedness constraints? These constraints check if an XML document follows the XML metasyntax and any XML processor is required to fail [1] on errors in these contraints. And browsers do that.
[1] https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-conforman...
In practice most well-formedness violations were nesting errors like missing start or end tags, common when generating XML via text concatenation or templates, which in the dark times a lot of people do, even when they shouldn't . [2] That's why the HTML5 parsing algorithm is so complex and almost unimplementable. It's the ambition for error correction: It tries to generate a DOM out of any well-formed and unwell-formed documents.
That's not to say the displayed technique is "wrong". It's interesting, clever, and a great exploration of the semantics.
Thanks for sharing the link!
I feel we should not have carried over superscript formatting from print to CSS/HTML/ePub. It makes no sense to create such tiny links that are difficult to click or tap. (It's fine to keep the semantic meaning of the tag, but format it so that is not so small.)
I want my electronic documents to do it better, with true re-rendering and inline/overlay display on demand. But it is partly a matter of taste, and there is also something to be said for a degree of skeuomorphism.
Part of the problem with footnotes is that they must be rendered in completely different ways depending on the device. It is annoying that there really isn't a good way of expressing that something should be a footnote attached to a particular piece of text in HTML. Depending on the stylesheet, this should be rendered as an expandable in-line span, a floating block off to the side, or a footnote at the bottom of the document or printed page (for printouts or PDFs).
My website uses a modified version of the tafte.css project, which meets _some_ of requirements in a sort-of hacky way.
The tack that Wikipedia has taken ... hover over the note# and a floating box reveals the note (and any links) ... IMO is state-of-the-art. I hate wasting time making stuff 'pretty print' - time that could have been much better spent improving the content instead of mere aesthetics.
While the world catches up with WPedia, this 'details' method has a lot going for it.
A downside to details/summary for footnotes is you can't find the footnote text in page using Cmd/Ctrl+F.
"Disclosure widgets" are a common pattern on the web so it's good that there's an HTML-native form of them. Two reasons why they're not used more is 1) they're HTML5 so IE didn't support them (neither did Edge before Chromium) and 2) the transition isn't currently animatable.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/de...
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/su...
I tried changing your example to have the transition be on the <detail> element itself instead of the child <p> but it didn't work, maybe that's what the MDN note is about.
Just be sure to use a keyframe to turn off the scroll when animating or it looks awful.
This was designed to be an experimental way of doing in-line notes.
As per the title, it isn't a particularly great way of dong it. But I thought it was interesting.