Skip to main content

Modern HTML: Built-In Features for Today's Web

Ten years ago, a pop-up window, a tooltip, or a reusable widget meant a JavaScript library, a pile of extra code, and a lot of accessibility bugs. Today HTML itself can do much of this work. The browser handles focus, the Escape key, layering, and screen reader announcements, and you write a few lines of markup.

This section shows you those features: what each one does, how to use it safely, and what to do for visitors whose browsers do not have it yet.

What You Will Learn​

  • Why HTML is now a "living standard", and what that means for you
  • How to tell whether a new feature is safe to use
  • What dialog, details, popover, inert, template, slot, native lazy loading, and web components are for
  • How to build on a solid base and add modern features on top
  • How to check support in your own code

The Big Idea​

A rule of thumb for the modern web: if HTML or CSS can do it, let them. Built-in features are usually shorter, faster, and more accessible than a hand-written version. They are also tested by browser makers, on more devices than you will ever own.

index.html
<!-- A modal dialog, with focus handling and Escape built in -->
<button type="button" id="open">Open settings</button>
<dialog id="settings">
<h2>Settings</h2>
<form method="dialog">
<button>Close</button>
</form>
</dialog>

<!-- A show-and-hide section with no JavaScript -->
<details>
<summary>Delivery information</summary>
<p>Orders ship within two working days.</p>
</details>

<!-- A popover opened by a button, also with no JavaScript -->
<button type="button" popovertarget="tips">Tips</button>
<div id="tips" popover>Press Escape to close this.</div>

<script>
document.getElementById("open").addEventListener("click", function () {
document.getElementById("settings").showModal();
});
</script>

HTML Is a Living Standard​

You may have heard of HTML5. It was a big milestone, around 2014, but it was not the end of the story. Today, HTML is maintained as a living standard by an open group called the WHATWG, together with browser makers. There is no "HTML6" to wait for. Instead, the specification changes continuously, small features are added, and browsers ship them one by one.

That changes how you work:

  • Features arrive at different times in different browsers. A feature can work in one browser this year and in another next year.
  • "What version of HTML?" is the wrong question. The right one is "do my visitors' browsers support this feature?"
  • Learning never finishes, but the base is stable. Elements you learned years ago still work.

The next lesson, The HTML Living Standard, explains how this works in practice and where to read the real specification.

Can I Use This Feature?​

Before you rely on any new feature, check support. A few reliable places are:

  • MDN Web Docs. Each page has a browser compatibility table at the bottom.
  • Baseline. A shared label from browser makers that tells you how widely a feature works. Newly available means it works in the latest versions of all the major browsers. Widely available means it has worked in all of them for at least about two and a half years, so it is safe for most sites.
  • Can I use. A site that shows support by browser version and usage share.

Then decide what fits your visitors. A site for a tech-savvy audience on current phones can use newer features sooner. A site for people on older, shared, or low-cost devices should wait for wider support, or provide a fallback.

From Old Way to Modern Way​

The jobThe old wayThe modern wayLesson
A modal pop-upA div, an overlay, a focus trap, many bugsdialog with showModal()Dialog
A show and hide sectionA click handler and a classdetails and summaryDetails and Summary
A tooltip, menu, or card that opens on demandA script, positioning code, click-outside handlingThe popover attributePopover
A block of markup used many timesStrings and innerHTMLtemplatetemplate
Content placed inside a componentCustom code to move nodes aroundslotslot
Blocking the background while a panel is openMany tabindex and aria-hidden changesThe inert attributeinert
Loading images and frames lateScroll listeners and observersloading="lazy"Lazy Loading
A reusable custom tagA framework, or copying and pastingCustom elements and shadow DOMWeb Components in HTML

Open the Old Way or New Way? tab and test yourself on this table.

What Is in This Section​

Progressive Enhancement​

The most useful habit for modern HTML is progressive enhancement: build a page that works with plain, widely supported HTML, then add newer features on top. If a feature is missing, the visitor gets the simple version, not a broken page.

A good example is details, which works as a heading and its content even if nothing else is available. Another is a link that goes to a full page, which a script upgrades into a pop-up when dialog is supported.

<!-- Works everywhere: a normal link to a full settings page -->
<a href="/settings" id="settings-link">Settings</a>
// Enhance it only where dialog is supported
const link = document.getElementById("settings-link");
if (typeof HTMLDialogElement === "function") {
link.addEventListener("click", function (event) {
event.preventDefault();
// open a dialog with the settings form here
});
}

Detecting features​

Check for the feature, not for the browser name. Browser names change, and visitors can disguise them. These are typical checks:

// Is the dialog element available?
const hasDialog = typeof HTMLDialogElement === "function";

// Is the popover attribute available?
const hasPopover = "popover" in HTMLElement.prototype;

// Does CSS understand a selector?
const hasPopoverOpen = CSS.supports("selector(:popover-open)");

The What Can Your Browser Do? tab above runs checks like these in your own browser. Compare the results with a friend's phone or an older device, if you can.

Using New Features Safely​

  1. Check support, on MDN or Baseline, and note the fallbacks.
  2. Start with a working base. Plain HTML first, features second.
  3. Test in more than one browser, and on a real phone, if you can.
  4. Use a polyfill only when you need it. A polyfill is a script that adds a missing feature. It adds weight, so weigh the cost.
  5. Check accessibility. Test with the keyboard alone, and with a screen reader if you can.
  6. Re-check from time to time. A feature that was not ready last year may be today.

Modern Does Not Mean Safe​

Built-in features save work, but they do not remove the need for the habits in the HTML Security section:

  • template and web components still need escaping when you put visitor text inside them. See XSS Basics.
  • A dialog or popover is not a security boundary. It only changes what is shown.
  • Shadow DOM is an organising tool, not a way to hide anything from scripts or attackers.
  • A new feature can have its own pitfalls, so read each lesson's security notes.

Accessibility at a Glance​

Built-in features come with keyboard and screen reader behaviour that you would otherwise have to rebuild:

  • dialog moves focus into the dialog, keeps it there when opened with showModal(), and closes with Escape.
  • details and summary can be opened with the keyboard, and announce their state.
  • popover handles light dismiss and the Escape key, and inert keeps hidden areas out of reach.

Your job is to use them as intended: add a heading and a way to close, write clear labels, and test with the keyboard. The existing lessons on Dialog and Details in the Semantic HTML section introduce those elements. The lessons here go further, with a modern focus and different examples.

Global Audience Notes​

  • Browser versions vary. Many visitors use older phones, shared computers, or devices that no longer get updates. Fallbacks protect them.
  • Data costs matter. A native feature usually costs fewer bytes than a library that does the same job.
  • Languages and writing directions differ. Test dialogs, popovers, and components with long words and right-to-left text, and avoid fixed widths.
  • Cultures differ in expectations. For example, a pop-up that blocks the page may be more irritating in some places than others. Use dialogs sparingly, and never trap people.

Common Mistakes to Avoid​

  1. Using a new feature without checking support.
  2. Replacing a working base with a feature-only version, so older browsers see nothing.
  3. Detecting the browser name instead of the feature.
  4. Adding a polyfill by habit, and paying for code you do not need.
  5. Rebuilding by hand something HTML already does.
  6. Skipping the keyboard test.
  7. Treating dialog, popover, or shadow DOM as security.
  8. Not re-checking support as browsers improve.
  9. Copying code that mixes old and new patterns without understanding it.
  10. Using modals for everything.

Practice Time​

  1. Open the What Can Your Browser Do? tab. How many features does your browser support? Which, if any, are missing?
  2. Open the same page in a second browser, and compare.
  3. Complete the Old Way or New Way? matcher.
  4. Choose one feature from the table, and look it up on MDN. What does its browser compatibility table say?
  5. Write the feature check you would use for inert.
  6. Pick a page of yours, and find one thing built by hand that a modern feature could replace.
  7. Write one sentence about a fallback for that feature.
  8. Bonus: find the Baseline label for popover on MDN.

Quick Recap​

Click a question to check your answer.

1. What does "living standard" mean?

HTML is no longer released in numbered versions. The specification is updated continuously, and browsers add features one by one.

2. How do you know a feature is safe to use?

Check browser support on MDN, Baseline, or Can I use, and think about which browsers your visitors really use.

3. What is progressive enhancement?

Building a page that works with plain, widely supported HTML, then adding newer features on top, so visitors without them still get a working page.

4. Why detect a feature instead of a browser?

Feature checks answer the question you care about, and they stay correct as browsers change. Browser names can be wrong or disguised.

5. Do modern features remove the need for security habits?

No. template, components, dialog, and popover still need escaping of visitor text, and none of them is a security boundary.

6. Why prefer a built-in feature to hand-written code?

It is usually shorter, faster, tested by browser makers, and brings keyboard and screen reader behaviour with it.

Key Takeaways​

  • HTML is a living standard. Features arrive over time, and support varies by browser.
  • Check support on MDN, Baseline, or Can I use, and think about your visitors.
  • Let HTML do what it can: dialogs, disclosure, popovers, templates, slots, inert regions, lazy loading, and components.
  • Build a working base first, then enhance it.
  • Detect features, not browsers.
  • Modern does not mean safe. Keep escaping, and keep testing with the keyboard.

Next up: The HTML Living Standard, where you will learn how HTML is specified, where to read it, and how a feature travels from an idea to your browser.