foot-notes
Progressive enhancement for footnotes with inline references and automatic collection.
Overview
The <foot-notes> component works with <foot-note> elements to create accessible footnotes. Without JavaScript, footnotes appear inline. With JavaScript, they become superscript links with a collected list at the bottom.
Components
<foot-note>
The footnote reference element. Place inline within your content where you want a footnote marker.
| Element | Content | Description |
|---|---|---|
<foot-note> |
Text | Contains the footnote text. Becomes a superscript link when enhanced. |
<foot-notes>
The footnotes container. Place at the end of your content where you want footnotes collected.
| Attribute | Type | Default | Description |
|---|---|---|---|
data-back-label |
string | "Back to content" |
Accessible label for back-reference links. |
Progressive Enhancement
The footnotes component demonstrates progressive enhancement principles.
Without JavaScript
When JavaScript is disabled or fails to load, footnotes remain inline within parentheses, keeping the content readable:
With JavaScript
When JavaScript loads, the component:
- Finds all
<foot-note>elements before the<foot-notes> - Converts them to superscript numbered links
- Collects footnote content into an ordered list
- Adds back-reference links from each footnote
Basic Usage
Place <foot-note> elements inline where footnotes should appear, then add a single <foot-notes> element where the footnote list should be rendered.
Custom Back Label
Use data-back-label to customize the accessible label for back-reference links.
The default label is "Back to content". Customize it for internationalization or to match your site's terminology.
Long Form Content
Footnotes work well with longer articles and prose content.
How It Works
The component processes footnotes in the following steps:
- Collection: Finds all
<foot-note>elements that appear before the<foot-notes>element in document order. - Enhancement: Each
<foot-note>gets:- A unique ID (e.g.,
fnref-1) - A
data-enhancedattribute - The original content wrapped in a span
- A superscript link to the footnote
- A unique ID (e.g.,
- List Generation: An ordered list is created inside
<foot-notes>with:- Each footnote's content
- A back-reference link to the original location
Generated HTML
Accessibility
ARIA Attributes
- Footnote links have
aria-describedbypointing to the footnote content - Back-reference links have
aria-labelfor screen reader context
Navigation
- Clicking a footnote number jumps to the footnote in the list
- Clicking the back-reference returns to the original location
- All links are keyboard accessible
Screen Reader Experience
Screen readers will:
- Announce the footnote number as a link
- Read the footnote content when navigating to it
- Allow users to return to their reading position
Best Practices
- Keep footnote content concise
- Don't put essential information only in footnotes
- Use footnotes for supplementary information, citations, or clarifications
- Place
<foot-notes>at the end of the content section
Styling
The component can be styled using CSS selectors.
Multiple Footnote Sections
You can have multiple <foot-notes> elements in a document. Each will collect only the footnotes that appear before it.
Sidenote Mode
Add data-mode="sidenotes" to <foot-notes> to place footnotes as margin annotations alongside the text instead of collecting them at the bottom. The authored markup is identical to regular footnotes.
Three-Layer Degradation
- No JS:
<foot-note>content appears inline in parentheses — the standard progressive enhancement fallback. - JS + narrow viewport: Falls back to numbered sidenotes that collapse to bordered blocks via CSS responsive rules.
- JS + wide viewport: Superscript numbered links at each reference point, with note content floated into the margin alongside the text.
Per-Note Opt-Out
Individual footnotes can opt out of sidenote placement with data-side="false". These notes are collected into the footnote list instead. Useful for longer notes that would overwhelm the margin.
Sidenote Mode Attributes
On <foot-notes>
| Attribute | Value | Description |
|---|---|---|
data-mode |
"sidenotes" |
Enables sidenote mode — notes are placed as margin annotations instead of collected at the bottom. |
On <foot-note>
| Attribute | Value | Description |
|---|---|---|
data-side |
"false" |
Opts this note out of sidenote placement. It will appear in the collected footnote list instead. |
Use Cases
Academic Writing
Citations and references in scholarly articles:
Legal Documents
Definitions and clarifications in terms of service:
Technical Documentation
Additional context or caveats:
Limitations
- Footnote numbering is determined by document order, not insertion order
- The component doesn't support dynamically added footnotes after initial render
- Rich HTML content in footnotes (links, formatting) is supported but may require additional styling