{"id":3092,"date":"2021-11-02T15:23:06","date_gmt":"2021-11-02T15:23:06","guid":{"rendered":"https:\/\/rengga.dev\/blog\/?p=3092"},"modified":"2023-06-12T14:43:17","modified_gmt":"2023-06-12T14:43:17","slug":"css-tutorial-a-terrible-way-to-do-footnotes-in-html","status":"publish","type":"post","link":"https:\/\/rengga.dev\/blog\/css-tutorial-a-terrible-way-to-do-footnotes-in-html\/","title":{"rendered":"CSS Tutorial &#8211; A (terrible?) way to do footnotes in HTML"},"content":{"rendered":"<p><span style=\"color: #ef3207;\"><a style=\"color: #ef3207;\" href=\"https:\/\/rengga.dev\/\" target=\"_blank\" rel=\"noopener\"><strong>Rengga Dev<\/strong><\/a> <\/span>&#8211; Terence Eden\u00a0<a href=\"https:\/\/shkspr.mobi\/blog\/2020\/12\/a-terrible-way-to-do-footnotes-in-html\/\" rel=\"noopener\">poked around<\/a>\u00a0with a way to do footnotes using the\u00a0<code>&lt;details&gt;<\/code>\/<code>&lt;summary&gt;<\/code>\u00a0elements. I think it\u2019s kind of clever. Rather than a hyperlink that jumps down to explain the footnote elsewhere, the details are right there next to the text. I like that proximity in the code. Plus, you get the native open\/close interactivity of the disclosure widget.<\/p>\n<p>It\u2019s got some tricky parts though. The\u00a0<code>&lt;details&gt;<\/code>\u00a0element is block-level, so it needs to become inline to be the footnote, and sized\/positioned to look \u201cright.\u201d I think it\u2019s a shame that it won\u2019t sit within a\u00a0<code>&lt;p&gt;<\/code>\u00a0tag, so that makes it impractical for my own usage.<\/p>\n<p>Craig Shoemaker in the comments forked the original to fiddle with the CSS, and that inspired me to do the same.<\/p>\n<p>Rather than display the footnote text itself right inline (which is extra-tricky), I moved that content to a fixed-position location at the bottom of the page:<\/p>\n<div class=\"mceTemp\"><\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\">&lt;div class=\"fake-p\"&gt;\r\n  The most cited work in history, for example, is a 1951 paper&lt;details&gt;\r\n    &lt;summary&gt;1&lt;\/summary&gt;\r\n    &lt;div class=\"details-content\"&gt;Lowry, O. H., Rosebrough, N. J., Farr, A. L. &amp; Randall, R. J. J. Biol. Chem. 193, 265\u2013275 (1951).&lt;\/div&gt;\r\n  &lt;\/details&gt; describing an assay to determine the amount of protein in a solution.\r\n&lt;\/div&gt;\r\n\r\n&lt;div class=\"fake-p\"&gt;\r\n  Sunlight poured like molten gold&lt;details&gt;\r\n    &lt;summary&gt;2&lt;\/summary&gt;\r\n    &lt;div class=\"details-content\"&gt;Not precisely, of course. Trees didn\u2019t burst into flame, people didn\u2019t suddenly become very rich and extremely dead, and the seas didn\u2019t flash into steam. A better simile, in fact, would be \u2018not like molten gold.\u2019&lt;\/div&gt;\r\n  &lt;\/details&gt; across the sleeping landscape.\r\n&lt;\/div&gt;\r\n\r\n&lt;div class=\"fake-p\"&gt;\r\n  My blog was recently featured in an academic paper&lt;details&gt;\r\n    &lt;summary&gt;3&lt;\/summary&gt;\r\n    &lt;div class=\"details-content\"&gt;&lt;span itemscope itemtype=\"http:\/\/schema.org\/ScholarlyArticle\"&gt;&lt;span itemprop=\"citation\"&gt;&lt;span itemprop=\"author\" itemscope itemtype=\"http:\/\/schema.org\/Person\"&gt;&lt;span itemprop=\"name\"&gt;&lt;span itemprop=\"familyName\"&gt;Eishita&lt;\/span&gt;&lt;span&gt;, &lt;\/span&gt;&lt;span itemprop=\"givenName\"&gt;Farjana Z.&lt;\/span&gt;&lt;\/span&gt;&lt;\/span&gt;&lt;span&gt; &amp; &lt;\/span&gt;&lt;span itemprop=\"author\" itemscope itemtype=\"http:\/\/schema.org\/Person\"&gt;&lt;span itemprop=\"name\"&gt;&lt;span itemprop=\"familyName\"&gt;Stanley&lt;\/span&gt;&lt;span&gt;, &lt;\/span&gt;&lt;span itemprop=\"givenName\"&gt;Kevin G.&lt;\/span&gt;&lt;\/span&gt;&lt;\/span&gt;&lt;span&gt; &amp; &lt;\/span&gt;&lt;span itemprop=\"author\" itemscope itemtype=\"http:\/\/schema.org\/Person\"&gt;&lt;span itemprop=\"name\"&gt;&lt;span itemprop=\"familyName\"&gt;Esquivel&lt;\/span&gt;&lt;span&gt;, &lt;\/span&gt;&lt;span itemprop=\"givenName\"&gt;Alain&lt;\/span&gt;&lt;\/span&gt;&lt;\/span&gt; &lt;q&gt;&lt;cite itemprop=\"headline\"&gt;Quantifying the differential impact of sensor noise in augmented reality gaming input&lt;\/cite&gt;&lt;\/q&gt; &lt;span&gt;(&lt;\/span&gt;&lt;time itemprop=\"datePublished\" datetime=\"2015\"&gt;2015&lt;\/time&gt;&lt;span&gt;)&lt;\/span&gt; &lt;span itemprop=\"publisher\" itemscope itemtype=\"http:\/\/schema.org\/Organization\"&gt;&lt;span itemprop=\"name\"&gt;Institute of Electrical and Electronics Engineers (IEEE)&lt;\/span&gt;&lt;\/span&gt;&lt;span&gt;.&lt;\/span&gt; DOI: &lt;a itemprop=\"url\" href=\"https:\/\/doi.org\/10.1109\/gem.2015.7377202\"&gt;https:\/\/doi.org\/10.1109\/gem.2015.7377202&lt;\/a&gt;&lt;\/span&gt;&lt;\/span&gt;&lt;\/div&gt;\r\n  &lt;\/details&gt; which pleased me greatly.\r\n&lt;\/div&gt;<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">details,\r\nsummary {\r\n  display: inline;\r\n  vertical-align: super;\r\n  font-size: 0.75rem;\r\n  padding: 0 0.25rem;\r\n}\r\nsummary {\r\n  cursor: pointer;\r\n}\r\n.details-content {\r\n  position: fixed;\r\n  bottom: 0;\r\n  left: 50%;\r\n  transform: translateX(-50%);\r\n  max-width: 90%;\r\n  padding: 1rem;\r\n  font-size: 1rem;\r\n  background: lightyellow;\r\n  box-shadow: 0 0 100px black;\r\n  border-top-left-radius: 4px;\r\n  border-top-right-radius: 4px;\r\n}\r\n\r\n\/* Details don't like being inside a p *\/\r\n.fake-p {\r\n  margin: 0 0 1rem 0;\r\n}\r\n\r\nbody {\r\n  font: 100%\/1.4 system-ui;\r\n  margin: 0;\r\n  padding: 2rem 2rem 20rem 2rem;\r\n}\r\n<\/pre>\n<p><iframe style=\"width: 100%;\" title=\"Footnotes in HTML\" src=\"https:\/\/codepen.io\/renggagumilar\/embed\/LYdqxzY?default-tab=result&amp;theme-id=dark\" height=\"300\" frameborder=\"no\" scrolling=\"no\" allowfullscreen=\"allowfullscreen\"><br \/>\nSee the Pen <a href=\"https:\/\/codepen.io\/renggagumilar\/pen\/LYdqxzY\"><br \/>\nFootnotes in HTML<\/a> by Rengga Gumilar (<a href=\"https:\/\/codepen.io\/renggagumilar\">@renggagumilar<\/a>)<br \/>\non <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<br \/>\n<\/iframe><br \/>\nI\u2019m not 100% convinced it\u2019s a good idea, but I\u2019m also not convinced it\u2019s a terrible one.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rengga Dev &#8211; Terence Eden\u00a0poked around\u00a0with a way to do footnotes using <a class=\"read-more\" href=\"https:\/\/rengga.dev\/blog\/css-tutorial-a-terrible-way-to-do-footnotes-in-html\/\" title=\"CSS Tutorial &#8211; A (terrible?) way to do footnotes in HTML\" itemprop=\"url\"><\/a><\/p>\n","protected":false},"author":1,"featured_media":3790,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,2],"tags":[268,197,288,103,227],"newstopic":[573,572],"class_list":{"0":"post-3092","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-html-css","8":"category-web-design","9":"tag-css-grid","10":"tag-css-tutorial","11":"tag-footnotes-in-html","12":"tag-web-design","13":"tag-web-designer","14":"newstopic-css","15":"newstopic-html"},"_links":{"self":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/3092","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/comments?post=3092"}],"version-history":[{"count":1,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/3092\/revisions"}],"predecessor-version":[{"id":3093,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/3092\/revisions\/3093"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/media\/3790"}],"wp:attachment":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/media?parent=3092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/categories?post=3092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/tags?post=3092"},{"taxonomy":"newstopic","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/newstopic?post=3092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}