Progressive Enhancement with Modern HTML
Every year the platform grows: new elements, new input types, new APIs with shorter names. The temptation is to ship them everywhere and let older browsers fail quietly. Progressive enhancement reverses that instinct. You build a complete, usable document with nothing but HTML, then layer CSS for presentation and JavaScript for behaviour, each layer guarded by detection rather than hope. The result is a page that degrades gracefully on a five-year-old browser, a locked-down corporate machine or a flaky connection β and a codebase where new features are additive instead of load-bearing.
Build the no-JS baseline first
The baseline is not a degraded stub; it is the actual product experience. Navigation is real anchors. Menus are real links or the details element. Forms submit to server endpoints and show results as new documents or server-rendered fragments. Content is in the initial HTML, so it appears with or without scripts, renders in reader modes, and gets indexed without waiting on a JavaScript runtime. Only after this baseline works do you enhance: intercept form submissions with fetch, animate transitions, open dialogs as modals instead of navigating. The order matters because scripts fail for reasons outside your control β a blocked CDN, a parse error, an aggressive content blocker β and the baseline is what users see on those days.
A practical test: disable JavaScript in dev tools and walk the critical path β browse, search, submit, recover from an error. Anything that breaks is a bug in the foundation, not an acceptable limitation. Then repeat with the network throttled to a mid-tier mobile connection, because scripts that race to hydrate a blank shell often produce a worse experience than no scripts at all.
Feature detection before feature use
User-agent sniffing guesses; feature detection knows. Test for the capability you are about to call, provide a fallback when it is missing, and never branch on browser brand strings. The pattern scales from one-line checks to async capability probes, and it composes with CSS @supports blocks so the same fallback decision can be made in both layers without duplicating logic.
<noscript>
<style>
.js-only { display: none !important; }
.noscript-banner { display: block; }
</style>
<p class="noscript-banner" role="status">
Interactive previews need JavaScript, but every article, price and
contact form on this page still works without it.
</p>
</noscript>
<dialog class="newsletter-dialog" id="newsletter" aria-labelledby="nl-title">
<form method="dialog">
<h2 id="nl-title">Get the weekly digest</h2>
<label for="nl-email">Email address</label>
<input id="nl-email" name="email" type="email" required autocomplete="email">
<menu>
<button value="cancel" type="submit">Not now</button>
<button value="subscribe" type="submit" class="primary">Subscribe</button>
</menu>
</form>
</dialog>
<picture>
<source srcset="/img/hero.avif" type="image/avif">
<source srcset="/img/hero.webp" type="image/webp">
<img src="/img/hero.jpg" alt="Team reviewing analytics on a large display"
width="1600" height="900" fetchpriority="high">
</picture>
<form class="search js-only" action="/search" method="get" data-enhanced>
<label for="q">Search the docs</label>
<input id="q" name="q" type="search" required placeholder="hooks, grid, fetchβ¦">
<button type="submit">Search</button>
</form>
<script>
document.querySelectorAll('[data-enhanced]').forEach((form) => {
form.addEventListener('submit', async (event) => {
event.preventDefault();
const params = new URLSearchParams(new FormData(form));
const results = await fetch('/api/search?' + params, {
headers: { Accept: 'application/json' }
});
if (!results.ok) {
form.submit();
return;
}
const panel = document.querySelector('#search-results');
const data = await results.json();
panel.replaceChildren(
...data.items.map((item) => {
const li = document.createElement('li');
const a = document.createElement('a');
a.href = item.url;
a.textContent = item.title;
li.append(a);
return li;
})
);
});
});
const dialog = document.querySelector('#newsletter');
if (dialog && typeof dialog.showModal === 'function') {
document.querySelector('[data-open-newsletter]').addEventListener('click', () => {
dialog.showModal();
});
} else if (dialog) {
dialog.setAttribute('open', '');
}
</script>
Three details carry the pattern. The noscript block hides enhancement-only chrome so nothing orphans when scripts are off. The search form keeps its action, so without JavaScript it performs a normal GET navigation; the listener only upgrades it to inline results, and any non-OK response falls back to a full submit. The dialog check calls showModal only when the method exists, and falls back to the plain open attribute.
Elements worth adopting β and how they degrade
Modern HTML offers several elements that replace substantial JavaScript while degrading to something usable. The dialog element brings native focus trapping, Escape-to-close and top-layer rendering; without support, a CSS-and-attribute fallback keeps the content readable. The picture element negotiates AVIF, WebP and JPEG automatically and degrades to the img inside it. details and summary implement disclosure widgets with zero script. New input types (email, date, color, range, search) bring specialized keyboards and validation, and unknown types fall back to plain text inputs β a graceful degradation by design.
| Feature | Enhanced behaviour | Fallback behaviour | Detection |
|---|---|---|---|
| dialog with showModal | Modal, focus-trapped overlay | Element renders inline or via open attribute | typeof dialog.showModal === 'function' |
| picture + source | AVIF or WebP chosen per browser | img src JPEG always works | No detection needed |
| details / summary | Click to expand | Same behaviour everywhere it is supported | Baseline in all current browsers |
| input type=date | Native picker and validation | Text input; validate server-side | Input valueAsNumber is a number when supported |
| fetch | Inline async results | Form performs normal navigation | 'fetch' in window |
| IntersectionObserver | Lazy content on approach | Load everything immediately | 'IntersectionObserver' in window |
The table is also a review checklist: for every modern feature on a page, you should be able to name both columns out loud.
Graceful degradation in the style layer
CSS deserves the same discipline. Container queries, :has(), scroll-driven animations and subgrid all shipped in the last few years, and each one can be introduced behind an @supports guard so browsers without the feature keep the previous layout instead of collapsing:
.card-list {
display: flex;
flex-wrap: wrap;
gap: 1rem;
}
@supports (container-type: inline-size) {
.card-container { container-type: inline-size; }
@container (min-width: 32rem) {
.card {
display: grid;
grid-template-columns: 12rem 1fr;
align-items: start;
}
}
}
.feature-list { list-style: none; padding: 0; }
@supports selector(:has(*)) {
.feature-list:has(:focus-within) {
outline: 2px solid var(--accent, #06c);
outline-offset: 4px;
}
}
@keyframes enter {
from { opacity: 0; transform: translateY(0.75rem); }
to { opacity: 1; transform: none; }
}
.reveal { opacity: 1; }
@supports (animation-timeline: view()) {
.reveal {
animation: enter linear both;
animation-timeline: view();
animation-range: entry 0% cover 30%;
}
}
@media (prefers-reduced-motion: reduce) {
.reveal { animation: none !important; }
}
The base rules are the fallback; the @supports blocks are the upgrade. Because CSS cascade applies the later rules only where the browser understands the query, you never ship a broken layout to a browser that lacks the feature.
Polyfills: when they are worth it
A polyfill backfills a missing API in JavaScript so application code can call it uniformly. Use them when the API is small, well-specified and central to the experience β dialog, IntersectionObserver and fetch all have mature polyfills measured in a few kilobytes. Skip them when the feature is purely presentational and CSS already degrades fine, or when the polyfill would ship tens of kilobytes to a shrinking share of traffic. Load polyfills conditionally: a short inline script that feature-detects and appends the polyfill only when needed keeps the fast path fast.
Equally important is versioning discipline. As browser baselines rise, delete polyfills and fallbacks you no longer support, and record the support window in the project docs so the team argues about data instead of anecdotes.
A pattern inventory for real projects
Before calling a page modern, inventory its features against this list. Content: fully present in the initial HTML, visible with scripts disabled. Navigation: real anchors, enhanced with client routing only when the framework truly needs it. Forms: working GET and POST submissions, upgraded with fetch behind detection. Media: picture with modern formats first and a JPEG or PNG last-resort source, dimensions set for layout stability. Dialogs and disclosures: dialog and details before any custom overlay code. Styling: base rules for every capability, @supports upgrades, prefers-reduced-motion respected. Script delivery: deferred or modular, polyfilled conditionally, removed once the baseline moves.
That inventory is the essence of progressive enhancement in 2026 β not nostalgia for a JavaScript-free web, but a systematic guarantee that the platform's growth makes your pages better for everyone and worse for no one.
Common Mistakes
Rendering the entire content tree from JavaScript and leaving the HTML shell empty
Fix: Ship content in the initial response; hydrate or enhance afterward so slow devices and crawlers both get the real page.
Sniffing browser strings to decide whether to call a modern API
Fix: Detect the capability itself, such as typeof dialog.showModal === 'function', and branch on the result.
Removing a form's action because fetch now handles submission
Fix: Keep the server endpoint and the action attribute; let the listener prevent default only when the request succeeds.
Adding polyfills unconditionally to every page
Fix: Feature-detect first, load the polyfill only when the API is missing, and delete it once your support baseline includes the API natively.
Using :has() or container queries with no fallback rule at all
Fix: Write the base layout with universally supported properties, then override inside an @supports block for capable browsers.
Testing only in the newest evergreen browser
Fix: Walk the critical path with JavaScript disabled, with reduced motion enabled, and on an older device profile at least once per release.
Key Takeaways
- Progressive enhancement starts from a complete HTML baseline β real links, real form actions, real content β and adds CSS and JavaScript as upgrades.
- Feature detection replaces user-agent sniffing: check for the capability, provide the fallback, never trust brand strings.
- dialog, picture, details and the newer input types deliver large wins with natural degradation paths.
- CSS capabilities belong behind @supports guards, with prefers-reduced-motion respected for anything animated.
- Polyfills are justified when the API is small, central and conditionally loaded β and deleted when the baseline rises.
- The result is resilience: pages that survive old browsers, flaky networks and blocked scripts without becoming second-class experiences.