Progressive enhancement and maintainable markup
A robust page delivers its core information first, then adds optional behavior without making the content depend on it.
✓ What you will learn in this topic
- Explain the purpose of Progressive enhancement and maintainable markup in a real HTML document.
- Choose and apply the elements shown in both examples.
- Recognize the specific mistake described in this lesson.
Concept explanation
Progressive enhancement starts with meaningful HTML and native browser behavior. CSS can improve presentation, and JavaScript can enhance interactions, but the central content and basic navigation should remain useful if scripts fail. Keep selectors and component boundaries predictable, avoid meaningless wrapper layers, and ensure the server-rendered document has headings, links, and labels before hydration or enhancement occurs.
Syntax
Place essential content and actions in HTML, then attach optional behavior without removing the meaningful base experience.
Example 1: a small page
The browser provides a working disclosure without a custom script.
<details>
<summary>Read the delivery policy</summary>
<p>Orders ship within two working days.</p>
</details>Expected result: The policy can be opened and read even when JavaScript is unavailable.
Example 2: a practical page
The schedule and session link remain useful; JavaScript can progressively add the save action.
<main>
<h1>Workshop schedule</h1>
<ul><li><a href=\"/sessions/morning\">Morning session</a></li></ul>
<button type=\"button\" data-action=\"save-schedule\">Save schedule</button>
</main>Expected result: Visitors can read and navigate the schedule before any enhancement script loads.
Common mistakes
Do not render user-controlled template values as raw HTML unless they have been safely sanitized for that context.
Best practices
Keep templates readable, escape dynamic values by default, and preserve useful server-rendered content when JavaScript is unavailable.
Practice exercise
Create a server-rendered article template with escaped title and body text, a semantic layout, and a small JavaScript enhancement that leaves the content readable without scripts.
Lesson summary
- Deliver content and basic navigation in HTML, then enhance it without removing the useful base.
- Keep templates readable, escape dynamic values by default, and preserve useful server-rendered content when JavaScript is unavailable.
Knowledge check
What is the first layer in progressive enhancement?
Show the explanation
Meaningful HTML content and native behavior provide the base before optional styling and scripts.
Practical example
html<details>
<summary>Read the delivery policy</summary>
<p>Orders ship within two working days.</p>
</details>
Expected result:
The policy can be opened and read even when JavaScript is unavailable.
Hands-on practice task
Create a server-rendered article template with escaped title and body text, a semantic layout, and a small JavaScript enhancement that leaves the content readable without scripts.
In this section
Other lessons in HTML in Modern Applications
Broaden your knowledge