<side-note>
Tufte-style sidenotes for the modern web — as a single HTML element.
What it is
<side-note> is a custom HTML element
The convention is centuries old.
There's no framework requirement.
side="left". Notes can land on either
margin — the attribute uses logical sides, so
dir="rtl" flips them automatically.
Design choices
Each note is rendered inside an open shadow root
<span> for the
superscript marker, and an <aside> for the
note's body. The <aside> is HTML's semantic
wrapper for tangentially related content, and screen readers
announce it appropriately.
Numbering uses CSS counters
counter-reset: sidenote on the container and
counter-increment: sidenote on each note element.
The counter value is read by both the marker and the margin
note, keeping them visually in sync without any JavaScript
bookkeeping.
label="*" overrides the auto-incremented
number. Useful for editorial notes that should read distinct
from numbered citations.
label attribute.
For positioning, the note is absolutely positioned against the
nearest .has-sidenotes ancestor,
position: relative and reserves
a right-side gutter via padding-inline-end. The
component injects this stylesheet into the document head once
on first connect — no setup required beyond adding the wrapper
class.
Authoring
Wrap a prose container in class="has-sidenotes" and
drop the element inline:
<article class="has-sidenotes">
<p>
Some prose
<side-note>A note in the margin.</side-note>
continues on.
</p>
</article>
The note's body accepts any inline content
inline code, emphasis, and any other
phrasing content the author needs. Styling stays consistent
because the host inherits the document's font.
Notes are responsive without any JavaScript: at narrow viewports
they flow inline as italic parentheticals after their markers,
and at wide viewports they float into the margin.
inline attribute keeps the
note in the flow of the prose at any width. Handy for short
asides that don't need full marginal treatment.
inline attribute.