HTML Progressive Enhancement and Noscript
Start with a working baseline
Progressive enhancement starts with meaningful HTML that works without optional features. Add richer behavior only when available. A native disclosure widget already opens with keyboard or pointer in supporting browsers, so there is no need to recreate it with custom JavaScript.
<details> <summary>Reading tips</summary> <p>Read one section and practice it.</p></details>Activate the summary. Details opens without a script.
Explain a scripting-dependent feature
In the body, noscript contains fallback HTML when scripting is disabled. It does not detect a failed fetch, a blocked individual script or a runtime exception while scripting remains enabled. Keep essential instructions outside it so all readers can access them.
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>Reading</title> </head> <body> <h1>Reading guide</h1> <p>Read the printed steps.</p> <noscript> <p id="fallback">Live preview requires JavaScript.</p> </noscript> </body></html>With scripting enabled, the fallback is not rendered as a paragraph. With scripting disabled it is visible.
Enhance only when available
Feature detection checks whether a needed capability exists, rather than guessing from browser names. The guide link below always works as a fragment link. The optional button is initially hidden; a script reveals it only if the dialog method exists. The dialog has a native close form.
<a href="#guide">Read guide</a><button id="preview" type="button" hidden>Quick preview</button><h2 id="guide">Guide</h2><p>Read and practice.</p><dialog id="panel" aria-label="Quick preview"> <p>Read and practice.</p> <form method="dialog"> <button>Close</button> </form></dialog><script> const panel = document.getElementById("panel"); const preview = document.getElementById("preview"); if (typeof panel.showModal === "function") { preview.addEventListener("click", () => panel.showModal()); preview.hidden = false; }</script>The baseline link remains available; supporting browsers reveal a working preview button.
Common mistakes and practice
Feature detection is not proof of correct or accessible implementation. Test the enhanced and baseline paths, keyboard navigation, focus and script failures. Do not hide core content until a script runs. noscript is not a replacement for error handling. In production a server may supply the baseline action; these examples avoid network dependencies.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Progressive Enhancement and Noscript — Knowledge Check
Apply the integration concepts taught in this lesson.
What is the starting point for progressive enhancement?
When does body noscript provide fallback markup?
How can a dialog method be checked?
When should an optional enhanced control be revealed?
Which testing approach is appropriate?