HTML Compatibility and Progressive Enhancement
Start with a usable baseline
Progressive enhancement preserves meaningful content when optional browser features are missing. Native links, headings and disclosure controls provide a baseline. Feature detection checks a specific capability rather than guessing from a browser name. This example always exposes the native details content.
<details open> <summary>Study notes</summary> <p>Read the reference first.</p></details>The open disclosure displays its notes.
Enhance only if the required API exists
Use a method check before enabling optional modal behavior. The details fallback remains available even without JavaScript. The optional button is hidden initially, and the script reveals it only when showModal exists. The dialog has an explicit accessible name and a native close form.
<details> <summary>Help</summary> <p>Read the guide.</p></details><button id="extra" type="button" hidden>Open help dialog</button><dialog id="help" aria-label="Help"> <p>Read the guide.</p> <form method="dialog"> <button>Close</button> </form></dialog><script> const dialog = document.querySelector("#help"); const button = document.querySelector("#extra"); if (typeof dialog.showModal === "function") { button.hidden = false; button.addEventListener("click", () => dialog.showModal()); }</script>The enhancement is enabled only when supported.
Check the specific feature, then test
Attribute reflection and API existence are useful signals, but neither proves all behavior, accessibility or compatibility. This example reports whether a specific image priority property exists. Consult feature-specific compatibility evidence, then test real behavior in target browsers and assistive technology.
<output id="result"></output><script> const image = document.createElement("img"); document.querySelector("#result").textContent = "fetchPriority" in image ? "Priority hint exposed" : "Default scheduling";</script>The report identifies whether the property is exposed.
Common mistakes and practice
Avoid browser-name checks and avoid declaring universal support based on one successful test. Keep a compatibility matrix for your targets, verify fallback with scripting disabled, and document limitations of new features. Do not make a core task depend on a cosmetic enhancement.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Compatibility and Progressive Enhancement — Knowledge Check
Apply the security, privacy and performance concepts taught in this lesson.
What should progressive enhancement preserve?
Which check detects a dialog method?
Does the presence of a reflected property prove full support?
Why hide an optional enhancement until initialized?
How should you verify compatibility?