Sidenote & Marginalia Reader
Tufte-inspired long-form essay reader with aligned right-margin sidenotes on desktop and tap-to-open popovers on mobile.
Inspired by Gwern.net ↗
WHY THIS AESTHETIC IS UNIQUE
Eliminates bottom-of-page footnote jumping by aligning numbered annotations directly beside their anchor sentences on desktop, then transforming them into smooth tap popovers on phones.
BEST FOR
TAGS
COLOR PALETTE (CLICK TO COPY HEX)
TYPOGRAPHY
- Display
- Newsreader
- Body
- Newsreader
- Mono
- JetBrains Mono
- Scale
- 34px editorial serif headline, 18px/1.72 body prose (~64ch measure), 13.5px/1.55 right-margin sidenotes.
ARCHITECTURE & MOBILE NOTES
LAYOUT
Asymmetric 2-column reading grid (66ch main prose + 260px right marginalia track) on desktop; single-column full-measure prose with inline interactive pills on <=900px.
INTERACTION
Hovering or clicking an inline superscript highlights its paired margin note on desktop; tapping a numbered pill on mobile opens a clean popover card; reading controls adjust type size and serif/sans.
MOBILE
Transforms wide margin columns into zero-overflow inline footnote pills with >=40px tap targets and dismissible annotation cards.
AI AGENT GUARDRAILS
DO
- Keep main prose measure between 58ch and 68ch even on wide desktop monitors.
- Visually link the inline anchor number and its margin note on hover/focus.
- Convert margin sidenotes to tap-to-open popovers or inline disclosures below 900px.
DON'T
- Never leave right-margin sidenotes overflowing off-screen on 390px mobile.
- Avoid microscopic superscript numbers that are impossible to tap with a thumb.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Marginalia — Sidenote Essay Reader</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
<style>
:root {
--paper: #fbf8f1;
--paper-card: #f4efe3;
--ink: #1e1c18;
--ink-muted: #5a5347;
--ink-faint: #867e70;
--rule: #e4dcc9;
--accent: #9b2c2c;
--accent-soft: rgba(155, 44, 44, 0.1);
--font-body: 'EB Garamond', Georgia, 'Times New Roman', serif;
--font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
--prose-size: 20px;
}
body[data-theme="sepia"] {
--paper: #f3ead8;
--paper-card: #e9dec8;
--ink: #292218;
--ink-muted: #5e513e;
--rule: #d8cab0;
--accent: #8b3a1a;
}
body[data-theme="night"] {
--paper: #171614;
--paper-card: #22201c;
--ink: #e8e2d5;
--ink-muted: #a69e8f;
--ink-faint: #787165;
--rule: #322f29;
--accent: #e07a5f;
--accent-soft: rgba(224, 122, 95, 0.16);
}
body[data-font="sans"] {
--font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
min-height: 100%;
background: var(--paper);
color: var(--ink);
font-family: var(--font-body);
-webkit-font-smoothing: antialiased;
transition: background 0.2s, color 0.2s;
overflow-x: hidden;
}
/* Reading Progress Line */
.progress-track {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 3px;
background: transparent;
z-index: 60;
}
.progress-fill {
height: 100%;
width: 0%;
background: var(--accent);
transition: width 0.08s linear;
}
/* Top Reading Controls */
.reader-bar {
position: sticky;
top: 0;
z-index: 40;
background: color-mix(in srgb, var(--paper) 92%, transparent);
backdrop-filter: blur(8px);
border-bottom: 1px solid var(--rule);
}
.reader-bar-inner {
max-width: 1080px;
margin: 0 auto;
padding: 10px 24px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.journal-mark {
font-family: var(--font-ui);
font-size: 12px;
font-weight: 600;
letter-spacing: 0.09em;
text-transform: uppercase;
color: var(--ink-muted);
white-space: nowrap;
}
.controls {
display: flex;
align-items: center;
gap: 6px;
flex-wrap: wrap;
}
.ctrl-btn {
appearance: none;
border: 1px solid var(--rule);
background: var(--paper-card);
color: var(--ink);
font-family: var(--font-ui);
font-size: 12.5px;
font-weight: 500;
min-height: 36px;
min-width: 36px;
padding: 0 10px;
border-radius: 7px;
cursor: pointer;
transition: border-color 0.15s, background 0.15s;
}
.ctrl-btn:hover {
border-color: var(--ink-faint);
}
.ctrl-btn.active {
border-color: var(--accent);
color: var(--accent);
background: var(--accent-soft);
}
/* Tufte Layout Container */
.essay-shell {
max-width: 1080px;
margin: 0 auto;
padding: 52px 24px 110px;
position: relative;
}
.essay-header {
max-width: 640px;
margin-bottom: 36px;
padding-bottom: 24px;
border-bottom: 1px solid var(--rule);
}
.kicker {
font-family: var(--font-ui);
font-size: 12px;
font-weight: 600;
letter-spacing: 0.1em;
text-transform: uppercase;
color: var(--accent);
margin-bottom: 12px;
}
.essay-title {
font-size: clamp(30px, 4.2vw, 44px);
line-height: 1.12;
font-weight: 500;
letter-spacing: -0.015em;
margin-bottom: 14px;
}
.essay-subtitle {
font-size: 20px;
line-height: 1.45;
color: var(--ink-muted);
font-style: italic;
margin-bottom: 16px;
}
.byline {
font-family: var(--font-ui);
font-size: 13px;
color: var(--ink-faint);
display: flex;
gap: 14px;
flex-wrap: wrap;
}
/* Essay Body with Right-Margin Sidenotes */
.essay-body {
position: relative;
max-width: 640px;
font-size: var(--prose-size);
line-height: 1.68;
}
body[data-font="sans"] .essay-body {
font-size: calc(var(--prose-size) - 2px);
line-height: 1.72;
}
.essay-body p {
margin-bottom: 1.35em;
position: relative;
}
.essay-body h2 {
font-size: 1.45em;
font-weight: 500;
margin: 1.8em 0 0.65em;
letter-spacing: -0.01em;
}
.dropcap::first-letter {
float: left;
font-size: 3.35em;
line-height: 0.84;
padding-right: 10px;
padding-top: 4px;
color: var(--accent);
font-weight: 500;
}
.pullquote {
margin: 1.6em 0;
padding: 6px 0 6px 22px;
border-left: 2px solid var(--accent);
font-style: italic;
color: var(--ink-muted);
font-size: 1.08em;
}
/* Sidenote Reference Button */
.sn-ref {
appearance: none;
border: 1px solid transparent;
background: var(--accent-soft);
color: var(--accent);
font-family: var(--font-ui);
font-size: 0.62em;
font-weight: 700;
vertical-align: super;
line-height: 1;
padding: 3px 6px;
border-radius: 99px;
cursor: pointer;
margin: 0 2px;
transition: background 0.15s, color 0.15s, transform 0.1s;
}
.sn-ref:hover,
.sn-ref.active {
background: var(--accent);
color: #fff;
}
/* Desktop Margin Sidenote */
.sidenote {
float: right;
clear: right;
margin-right: -340px;
width: 288px;
margin-top: 4px;
margin-bottom: 18px;
padding: 10px 14px;
border-left: 2px solid var(--rule);
font-size: 15px;
line-height: 1.5;
color: var(--ink-muted);
border-radius: 0 8px 8px 0;
transition: border-color 0.2s, background 0.2s, color 0.2s;
cursor: pointer;
}
.sidenote:hover,
.sidenote.highlighted {
border-left-color: var(--accent);
background: var(--paper-card);
color: var(--ink);
}
.sn-num {
font-family: var(--font-ui);
font-size: 11px;
font-weight: 700;
color: var(--accent);
margin-right: 6px;
}
.sn-figure {
margin-top: 8px;
padding: 8px;
background: var(--paper);
border: 1px solid var(--rule);
border-radius: 6px;
}
.sn-caption {
font-family: var(--font-ui);
font-size: 11px;
color: var(--ink-faint);
margin-top: 5px;
}
/* Mobile Popover Sheet */
.popover-backdrop {
position: fixed;
inset: 0;
background: rgba(15, 14, 12, 0.42);
opacity: 0;
pointer-events: none;
transition: opacity 0.2s;
z-index: 70;
}
.popover-backdrop.open {
opacity: 1;
pointer-events: auto;
}
.mobile-popover {
position: fixed;
left: 12px;
right: 12px;
bottom: 14px;
max-width: 480px;
margin: 0 auto;
background: var(--paper);
border: 1px solid var(--rule);
border-top: 3px solid var(--accent);
border-radius: 14px;
padding: 16px 18px 18px;
box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
transform: translateY(120%);
transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
z-index: 80;
}
.mobile-popover.open {
transform: translateY(0);
}
.pop-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
}
.pop-title {
font-family: var(--font-ui);
font-size: 12px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.06em;
color: var(--accent);
}
.pop-nav {
display: flex;
align-items: center;
gap: 6px;
}
.pop-btn {
appearance: none;
border: 1px solid var(--rule);
background: var(--paper-card);
color: var(--ink);
font-family: var(--font-ui);
font-size: 13px;
min-width: 44px;
min-height: 44px;
border-radius: 8px;
cursor: pointer;
}
.pop-body {
font-size: 17px;
line-height: 1.55;
color: var(--ink);
}
/* Responsive Transformation at <= 1020px (includes 390px mobile) */
@media (max-width: 1020px) {
.essay-shell {
padding: 32px 18px 80px;
}
.essay-header, .essay-body {
max-width: 65ch;
margin-left: auto;
margin-right: auto;
}
.sidenote {
display: none;
}
.sn-ref {
vertical-align: baseline;
font-size: 0.72em;
padding: 4px 9px;
min-height: 28px;
display: inline-flex;
align-items: center;
justify-content: center;
}
.reader-bar-inner {
padding: 8px 14px;
}
.ctrl-btn {
min-height: 44px;
min-width: 44px;
}
}
</style>
</head>
<body data-theme="paper" data-font="serif">
<div class="progress-track"><div id="progressFill" class="progress-fill"></div></div>
<header class="reader-bar">
<div class="reader-bar-inner">
<div class="journal-mark">Marginalia · No. 14</div>
<div class="controls" role="toolbar" aria-label="Reading controls">
<button id="fontDown" class="ctrl-btn" type="button" aria-label="Decrease font size">A−</button>
<button id="fontUp" class="ctrl-btn" type="button" aria-label="Increase font size">A+</button>
<button id="fontToggle" class="ctrl-btn" type="button">Serif</button>
<button class="ctrl-btn active" type="button" data-theme-btn="paper">Ivory</button>
<button class="ctrl-btn" type="button" data-theme-btn="sepia">Sepia</button>
<button class="ctrl-btn" type="button" data-theme-btn="night">Night</button>
</div>
</div>
</header>
<article class="essay-shell">
<header class="essay-header">
<div class="kicker">Typography & Information Design</div>
<h1 class="essay-title">The Geometry of Margin Notes</h1>
<p class="essay-subtitle">Why spatial proximity in the right margin preserves reading flow better than endnotes—and how to adapt the pattern for narrow screens.</p>
<div class="byline">
<span>By Clara Lindholm</span>
<span>·</span>
<span>6 min read</span>
<span>·</span>
<span>5 sidenotes</span>
</div>
</header>
<div class="essay-body" id="essayBody">
<p class="dropcap">
A footnote asks the reader to perform a small act of faith: abandon the current sentence, descend to the bottom of the page, locate a matching numeral, and climb back without losing the clause that prompted the detour.<button class="sn-ref" type="button" data-note="1" aria-label="Sidenote 1">1</button>
<aside class="sidenote" data-note="1">
<span class="sn-num">1</span>Robert Bringhurst notes in <em>The Elements of Typographic Style</em> that marginalia were standard in Renaissance codices long before printers moved notes to the foot of the sheet to save paper.
</aside>
On the web, where pages have no physical bottom, endnotes become even more disruptive—turning a glance into a round-trip scroll across thousands of pixels.
</p>
<p>
Edward Tufte popularized the revival of the wide right margin precisely because human peripheral vision resolves horizontal adjacency effortlessly.<button class="sn-ref" type="button" data-note="2" aria-label="Sidenote 2">2</button>
<aside class="sidenote" data-note="2">
<span class="sn-num">2</span>Eye-tracking studies on academic layouts show readers return to the primary line 2.4× faster from an aligned margin note than from a bottom-of-page footnote.
<div class="sn-figure">
<svg viewBox="0 0 220 56" width="100%" height="56" aria-label="Return latency comparison chart">
<text x="2" y="16" font-family="Inter, sans-serif" font-size="10" fill="currentColor">Margin</text>
<rect x="52" y="7" width="54" height="12" rx="3" fill="#9b2c2c"/>
<text x="112" y="16" font-family="Inter, sans-serif" font-size="10" fill="currentColor">0.9s</text>
<text x="2" y="42" font-family="Inter, sans-serif" font-size="10" fill="currentColor">Endnote</text>
<rect x="52" y="33" width="132" height="12" rx="3" fill="#867e70" opacity="0.55"/>
<text x="190" y="42" font-family="Inter, sans-serif" font-size="10" fill="currentColor">2.2s</text>
</svg>
<div class="sn-caption">Median gaze-return latency (s) across 48 readers.</div>
</div>
</aside>
When commentary sits level with the sentence it qualifies, the reader treats it as an optional second voice rather than an interruption.
</p>
<h2>Measure, Whitespace, and the 65-Character Rule</h2>
<p>
Wide desktop monitors routinely tempt layouts into stretching prose across ninety or more characters per line. Yet classic book typography caps the optimal measure near sixty-five characters.<button class="sn-ref" type="button" data-note="3" aria-label="Sidenote 3">3</button>
<aside class="sidenote" data-note="3">
<span class="sn-num">3</span>A 640px text column at 20px Garamond averages 64–68 characters per line—leaving roughly 320px on a 1280px viewport for crisp marginalia without crowding.
</aside>
Rather than leaving that surplus horizontal space empty, a sidenote grid converts dead margin into an active layer for citations, caveats, and small data graphics.
</p>
<blockquote class="pullquote">
“The margin is not leftover paper; it is a parallel channel for evidence that would otherwise clog the main argument.”
</blockquote>
<p>
Long-form digital essays—from Gwern Branwen’s research notebooks to interactive technical monographs—rely on this dual channel to keep narrative momentum brisk while remaining rigorously sourced.<button class="sn-ref" type="button" data-note="4" aria-label="Sidenote 4">4</button>
<aside class="sidenote" data-note="4">
<span class="sn-num">4</span>Notice how hovering or clicking either the superscript badge or the margin block itself links the pair visually, confirming correspondence at a glance.
</aside>
</p>
<h2>Adapting Marginalia for Pocket Screens</h2>
<p>
On a 390-pixel mobile viewport, there is no right margin to borrow. Forcing two columns onto a phone compresses prose into jagged three-word ribbons. Instead, the margin note must transform into an on-demand popover card triggered by tapping the inline reference pill.<button class="sn-ref" type="button" data-note="5" aria-label="Sidenote 5">5</button>
<aside class="sidenote" data-note="5">
<span class="sn-num">5</span>Resize the window below 1020px (or view on mobile) and tap any numbered badge to inspect this bottom-anchored popover card with Prev/Next note stepping.
</aside>
The semantic HTML stays identical—one source of truth—while the presentation honors the physical geometry of whichever glass the reader holds.
</p>
</div>
</article>
<div id="popoverBackdrop" class="popover-backdrop" aria-hidden="true"></div>
<div id="mobilePopover" class="mobile-popover" role="dialog" aria-modal="true" aria-label="Sidenote detail">
<div class="pop-head">
<span id="popTitle" class="pop-title">Sidenote 1 of 5</span>
<div class="pop-nav">
<button id="popPrev" class="pop-btn" type="button" aria-label="Previous note">‹</button>
<button id="popNext" class="pop-btn" type="button" aria-label="Next note">›</button>
<button id="popClose" class="pop-btn" type="button" aria-label="Close note">✕</button>
</div>
</div>
<div id="popBody" class="pop-body"></div>
</div>
<script>
const refs = Array.from(document.querySelectorAll('.sn-ref'));
const notes = Array.from(document.querySelectorAll('.sidenote'));
const backdrop = document.getElementById('popoverBackdrop');
const popover = document.getElementById('mobilePopover');
const popTitle = document.getElementById('popTitle');
const popBody = document.getElementById('popBody');
let activeNoteId = null;
let proseSize = 20;
function isMobileLayout() {
return window.innerWidth <= 1020;
}
function clearHighlights() {
refs.forEach(r => r.classList.remove('active'));
notes.forEach(n => n.classList.remove('highlighted'));
}
function highlightPair(id) {
clearHighlights();
const ref = document.querySelector(`.sn-ref[data-note="${id}"]`);
const note = document.querySelector(`.sidenote[data-note="${id}"]`);
if (ref) ref.classList.add('active');
if (note) note.classList.add('highlighted');
}
function openPopover(id) {
activeNoteId = Number(id);
const note = document.querySelector(`.sidenote[data-note="${id}"]`);
if (!note) return;
highlightPair(id);
popTitle.textContent = `Sidenote ${id} of ${notes.length}`;
// Clone note content without duplicate number badge
const clone = note.cloneNode(true);
const numEl = clone.querySelector('.sn-num');
if (numEl) numEl.remove();
popBody.innerHTML = clone.innerHTML;
backdrop.classList.add('open');
popover.classList.add('open');
}
function closePopover() {
backdrop.classList.remove('open');
popover.classList.remove('open');
clearHighlights();
activeNoteId = null;
}
refs.forEach(ref => {
const id = ref.dataset.note;
ref.addEventListener('mouseenter', () => {
if (!isMobileLayout()) highlightPair(id);
});
ref.addEventListener('mouseleave', () => {
if (!isMobileLayout() && activeNoteId === null) clearHighlights();
});
ref.addEventListener('click', () => {
if (isMobileLayout()) {
openPopover(id);
} else {
if (activeNoteId === Number(id)) {
activeNoteId = null;
clearHighlights();
} else {
activeNoteId = Number(id);
highlightPair(id);
}
}
});
});
notes.forEach(note => {
const id = note.dataset.note;
note.addEventListener('mouseenter', () => highlightPair(id));
note.addEventListener('mouseleave', () => {
if (activeNoteId === null) clearHighlights();
});
note.addEventListener('click', () => {
activeNoteId = Number(id);
highlightPair(id);
});
});
document.getElementById('popClose').addEventListener('click', closePopover);
backdrop.addEventListener('click', closePopover);
document.getElementById('popPrev').addEventListener('click', () => {
if (!activeNoteId) return;
const prev = activeNoteId === 1 ? notes.length : activeNoteId - 1;
openPopover(prev);
});
document.getElementById('popNext').addEventListener('click', () => {
if (!activeNoteId) return;
const next = activeNoteId === notes.length ? 1 : activeNoteId + 1;
openPopover(next);
});
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') closePopover();
});
// Reading controls
document.getElementById('fontDown').addEventListener('click', () => {
proseSize = Math.max(16, proseSize - 2);
document.documentElement.style.setProperty('--prose-size', `${proseSize}px`);
});
document.getElementById('fontUp').addEventListener('click', () => {
proseSize = Math.min(26, proseSize + 2);
document.documentElement.style.setProperty('--prose-size', `${proseSize}px`);
});
const fontToggle = document.getElementById('fontToggle');
fontToggle.addEventListener('click', () => {
const next = document.body.dataset.font === 'serif' ? 'sans' : 'serif';
document.body.dataset.font = next;
fontToggle.textContent = next === 'serif' ? 'Serif' : 'Sans';
});
document.querySelectorAll('[data-theme-btn]').forEach(btn => {
btn.addEventListener('click', () => {
document.body.dataset.theme = btn.dataset.themeBtn;
document.querySelectorAll('[data-theme-btn]').forEach(b => b.classList.remove('active'));
btn.classList.add('active');
});
});
// Scroll progress
function updateProgress() {
const scrollTop = window.scrollY;
const maxScroll = Math.max(1, document.documentElement.scrollHeight - window.innerHeight);
const pct = Math.min(100, Math.round((scrollTop / maxScroll) * 100));
document.getElementById('progressFill').style.width = `${pct}%`;
}
window.addEventListener('scroll', updateProgress, { passive: true });
updateProgress();
</script>
</body>
</html>