Re:A (terrible?) way to do footnotes in HTML
by hombre_fatal on Thursday December 10, 2020 @08:21AM
(#25373391)
Adequately marked up <a href="..." epub:type="noteref"> footnotes (actually called endnotes) are rendered nicely in epub readers like the Kindle: clicking on one opens it in a scrollable modal. I've seen some desktop ereader software render them as page footnotes.
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.
Re:A (terrible?) way to do footnotes in HTML
by vbernat on Thursday December 10, 2020 @10:55AM
(#25375010)
You cannot use details inside p. Only phrasing content is allowed and details is not one of them. So, it would be valid for some rendering engines to implicitly closes the paragraph at this point.
Re:A (terrible?) way to do footnotes in HTML
by chrismorgan on Friday December 11, 2020 @02:52AM
(#25383414)
On the contrary, XHTML was stricter. If you put an element where it’s not supposed to be, the whole document would (probably?) not render.
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.
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.
Re:A (terrible?) way to do footnotes in HTML
by chrismorgan on Friday December 11, 2020 @10:24AM
(#25386744)
Huh, I thought the XML serialisation of HTML had been evicted from all the browsers, but you’re right, and Firefox behaves the same way. https://html.spec.whatwg.org/#html-vs-xhtml describes briefly what is expected to occur (though that section is non-normative). Also given that I know that browsers can successfully load XML documents with XSLT (I’ve seen one or two web pages that actually do this), and that I know that the XML parser is accessible via DOMParser (this can be useful for some kinds of markup sanitisation), I’m not sure why I thought XHTML was completely dead in this way. Something’s niggling at the back of my mind, but I can’t place it.
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.
Re:A (terrible?) way to do footnotes in HTML
by ttepasse on Sunday December 13, 2020 @05:29PM
(#25411037)
> I’m not sure why I thought XHTML was completely dead in this way. Something’s niggling at the back of my mind, but I can’t place it.
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.
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.
Re:A (terrible?) way to do footnotes in HTML
by edent on Thursday December 10, 2020 @10:59AM
(#25375074)
Yes - I have cheated with my markup by just putting the text inside the body without p. It is valid in a div. Like I say, this is a terrible way to do it!
Re:A (terrible?) way to do footnotes in HTML
by the_other on Thursday December 10, 2020 @08:04AM
(#25373229)
This doesn't sit well, to me. I think it makes more sense to use `<sup>`s and `<a href>`s that point to `<a id>`s inside a `<footer>`. I think this conveys the meaning better.
That's not to say the displayed technique is "wrong". It's interesting, clever, and a great exploration of the semantics.
Re:A (terrible?) way to do footnotes in HTML
by dhosek on Thursday December 10, 2020 @09:26AM
(#25373979)
href footnotes are a usability disaster in my experience. Many (most?) don't have a jumpback link, and when the link is too close to the edge of the page it gets overridden by the prev/next page control. I've ended up giving up on reading footnotes in ebooks. If it weren't for coronavirus library closures, I would read a small fraction of the ebooks that I read right now.
Re:A (terrible?) way to do footnotes in HTML
by edent on Thursday December 10, 2020 @08:07AM
(#25373254)
Yup - that's how most ePubs do it now. Currently, eReaders handle that inconsistently. Some jump you down to the footnote and others display it on the same page.
Re:A (terrible?) way to do footnotes in HTML
by agustif on Thursday December 10, 2020 @07:59AM
(#25373186)
I don't know about using it for footnotes, but this seems a great way to handle spoilers natively in movie/tv related sites with user generated content.
Re:A (terrible?) way to do footnotes in HTML
by open-source-ux on Thursday December 10, 2020 @08:53AM
(#25373674)
I don't like this, I'm afraid.
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.)
Re:A (terrible?) way to do footnotes in HTML
by pwdisswordfish4 on Thursday December 10, 2020 @09:51AM
(#25374223)
Size of visual cue and size of hit target should not be conflated. In terms of visuals, it is a good idea for the marker to be presented as unobtrusively as possible.
Re:A (terrible?) way to do footnotes in HTML
by alex_stoddard on Thursday December 10, 2020 @09:39AM
(#25374105)
To me footnotes/endnotes exist as the least bad way of working with supplemental information within the constraints of the _printed_ page (i.e. it can't be dynamically re-rendered).
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.
Re:A (terrible?) way to do footnotes in HTML
by thrower123 on Thursday December 10, 2020 @08:21AM
(#25373392)
In the example, only the second footnote should even be a footnote - the other two should be endnotes. Citations should be endnotes, while asides, parentheticals, and other bits that someone might actually care to read should go in footnotes.
Re:A (terrible?) way to do footnotes in HTML
by dhosek on Thursday December 10, 2020 @09:30AM
(#25374017)
Unfortunately, few styles actually dictate this. I remember one anthology from my undergrad days which handled things perfectly: side notes for vocabulary notes (it was an anthology of older English literary texts), footnotes for commentary, end notes for text source notes (there weren't really citations per se so much as indications about where the anthologized text came from and choices about which edition/manuscript was followed for the text).
Re:A (terrible?) way to do footnotes in HTML
by AndrewStephens on Thursday December 10, 2020 @10:05AM
(#25374386)
I love using footnotes and sidetone in my writing and I have had this frustration myself.
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.
Re:A (terrible?) way to do footnotes in HTML
by 8bitsrule on Thursday December 10, 2020 @09:23PM
(#25381518)
In e-text, jumping down to read a footnote, then back up again is a hilarious anachronism that gets old really fast. Ted Nelson groan.
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.
Re:A (terrible?) way to do footnotes in HTML
by lecarore on Wednesday December 09, 2020 @08:14AM
(#25358113)
I had no idea there was a native be [open] CSS selector. It's the first time I hear about details too. Idk if that's a useful was to do footnotes, but I learned something today
Re:A (terrible?) way to do footnotes in HTML
by extra88 on Thursday December 10, 2020 @08:29AM
(#25373461)
Only the details element has the open attribute so you wouldn't hear about using it in CSS without hearing about it. BTW, you can use JavaScript to expand/collapse the element by setting and removing the attribute.
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.
Re:A (terrible?) way to do footnotes in HTML
by extra88 on Thursday December 10, 2020 @05:46PM
(#25379819)
Thanks, I was just going by the note on the MDN page.
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.
Re:A (terrible?) way to do footnotes in HTML
by capitainenemo on Thursday December 10, 2020 @05:51PM
(#25379868)
https://m8y.org/tmp/testcase491.xhtml transition on <detail>
And, yeah, the main "trick" is that it's tough to animate a height when the content is variable height. Thus the max-height and tweaked animation curve trick. But for many cases you'd probably want fixed height with scroll anyway.
Just be sure to use a keyframe to turn off the scroll when animating or it looks awful.
Re:A (terrible?) way to do footnotes in HTML
by edent on Thursday December 10, 2020 @11:17AM
(#25375264)
As I attempted to explain in the linked blog post - different eReaders render these sorts of links differently. Some link to the bottom of the page, some don't provide backwards navigation, some pop-up modals, some modals overflow.
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.
Re:A (terrible?) way to do footnotes in HTML
by leephillips on Thursday December 10, 2020 @03:16PM
(#25378005)
Ahh, I guess I should have been more specific. I can also select the footnote toggles by tabbing, and toggle them with the keyboard. But can’t select them in a random-access way with link hinting (I mentioned vimperator), because they are not links nor something else, such as an input field, that gets a hint. So that's a slight advantage on the side of using some kind of link for the footnotes. But really, this just shows me that link-hinting systems should include detail toggles as targets.
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:
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.
[2] https://hsivonen.fi/producing-xml/#nottext
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.
https://jsfiddle.net/jvuywL5k/
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.