Modern HTML Features
HTML keeps growing. Alongside big features such as dialog and popover, which have lessons of their own, there is a set of small, practical additions that make forms friendlier, pages faster, and content easier to use for a global audience. This lesson is a guided tour of them, followed by a method for judging whether any new feature is ready for your site.
What You Will Learnβ
- The
searchelement, a landmark for search forms inputmodeandenterkeyhint, which shape the phone keyboardfetchpriorityanddecoding, hints for images and resourceshidden="until-found",translate, andspellcheck- Module scripts and import maps
- A simple way to decide whether a feature is ready
The Big Ideaβ
Most modern features are hints and improvements, not new building blocks. If you add them to a solid page, browsers that understand them give visitors a better experience, and browsers that do not simply ignore them. That is the safest way to adopt new HTML.
- A Page Using Them
- Feature Matcher
- Readiness Judge
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bakery</title>
<!-- If you use a CSP, an inline import map needs a nonce or hash -->
<script type="importmap">
{ "imports": { "confetti": "/js/vendor/confetti.js" } }
</script>
<script type="module" src="/js/app.js"></script>
</head>
<body>
<header>
<search>
<form action="/search" method="get">
<label for="q">Search recipes</label>
<input id="q" type="search" name="q" enterkeyhint="search" spellcheck="false">
<button type="submit">Search</button>
</form>
</search>
</header>
<main>
<img src="/img/hero.jpg" alt="Fresh loaves on a wooden table"
width="1200" height="600" fetchpriority="high" decoding="async">
<p>Our shop is called <span translate="no">DoughNation</span>.</p>
<label for="code">Six-digit code</label>
<input id="code" type="text" inputmode="numeric" pattern="[0-9]{6}"
autocomplete="one-time-code" enterkeyhint="done">
</main>
</body>
</html>
Match each goal to the feature that does it.
Use it as an enhancement
Build a page that works without it, and let the feature improve things where it is available.
- It works in the latest versions of the major browsers, but older versions are still in use.
- Your visitors include older or shared devices.
- If the feature is missing, the page still works.
A rule of thumb, not a law. Your own visitor numbers and the cost of a failure should decide the final choice.
Browser support changes over time. The notes in this lesson describe how each feature behaves, not a fixed support table. Before you rely on one, check its Baseline label and compatibility table on MDN, as explained in the Modern HTML overview.
The search Elementβ
The search element marks the part of a page that holds search or filtering controls. It gives assistive technology a search landmark, so screen reader users can jump straight to it.
<search>
<form action="/search" method="get">
<label for="q">Search recipes</label>
<input id="q" type="search" name="q">
<button type="submit">Search</button>
</form>
</search>
Before it existed, you wrote <form role="search">. That still works, and is a sensible choice if you must support older browsers, because they treat an unknown element such as search as a plain wrapper with no landmark meaning. A search element is not a form, so keep a form inside it.
Use it for site search, and for filter panels on listing pages. Do not use it for anything that is not search.
inputmode and enterkeyhintβ
On a phone, the keyboard that appears depends on the field. Two attributes let you fine-tune it:
<input type="text" inputmode="numeric" pattern="[0-9]{6}" autocomplete="one-time-code">
<input type="search" enterkeyhint="search">
inputmodesuggests which keyboard to show. Common values arenumeric,decimal,tel,email,url, andsearch.enterkeyhintchanges the label or icon of the enter key. Values includeenter,done,go,next,previous,search, andsend.
Neither one validates anything, and both are only hints. A browser or keyboard may ignore them.
A good reason to use inputmodeβ
type="number" looks right for codes and card numbers, but it has problems: it adds spinner arrows, scrolling the mouse wheel can change the value, and it drops leading zeros. For a PIN or a postal code, use type="text" with inputmode="numeric" and a pattern, and validate on the server, as covered in Secure Forms.
For amounts with decimals, inputmode="decimal" shows a keyboard with a decimal key. Remember that some regions use a comma as the decimal mark, so accept both on the server.
fetchpriority and decodingβ
Two attributes help the browser decide what to load first and how to prepare an image.
<img src="/img/hero.jpg" alt="..." width="1200" height="600"
fetchpriority="high" decoding="async">
fetchpriorityacceptshigh,low, orauto. It nudges the browser's choice of when to download a resource. It works onimg,link, andscript. It is a hint, not a command.decoding="async"lets the browser decode an image away from the main flow of work, so the page stays responsive. The default isauto.
The best use of fetchpriority="high" is on the single image that is your Largest Contentful Paint element. Do not put it on many images, because then none of them stands out. See Core Web Vitals and Critical Resources.
hidden="until-found"β
The ordinary hidden attribute removes content from the page and from find-in-page. A newer value changes that:
<div hidden="until-found">
<p>Shipping takes two working days.</p>
</div>
With until-found, the content stays hidden until the visitor's find-in-page search or a link to a fragment matches it. Then the browser reveals it. A beforematch event fires so your script can react.
The catch is support: where it is missing, the content stays hidden and cannot be found. So use it only for content that is not essential, or consider details and summary, which have long been supported. See Details and Summary.
translate, spellcheck, and autocapitalizeβ
These global attributes are small, but they matter for people around the world:
<p>Our shop is called <span translate="no">DoughNation</span>.</p>
<code translate="no">npm install</code>
<input type="text" name="username" spellcheck="false" autocapitalize="none" autocomplete="username">
translate="no"tells page translators to leave the text alone. Use it for brand names, code, and product codes, so a translator does not turn them into nonsense.spellcheck="false"stops red underlines on usernames, codes, and other text that is not ordinary prose.autocapitalizecontrols automatic capital letters on mobile keyboards.noneis helpful for usernames and email addresses.
They cost almost nothing to add, and they help most on pages that visitors translate or open on many kinds of devices.
Module Scripts and Import Mapsβ
Modern JavaScript is written in modules, which are files that import and export values.
<script type="module" src="/js/app.js"></script>
What makes module scripts different from classic scripts:
- They are deferred by default, so they run after the page is parsed, like
deferin Script Loading. - They run in strict mode, and keep their variables to themselves.
- A browser loads each module once, even when several files import it.
An import map lets you use short names instead of long paths:
<script type="importmap">
{ "imports": { "confetti": "/js/vendor/confetti.js" } }
</script>
<script type="module">
import { launch } from "confetti";
launch();
</script>
The import map must come before the module scripts that use it.
If your site has a Content Security Policy, an inline import map or inline module is blocked unless it carries a nonce or matches a hash, exactly like any inline script. See Content Security Policy. Scripts from other origins also need the right crossorigin handling, so read the details before you add them.
Other Small Elements Worth Knowingβ
These are not new, but they are underused and worth a second look:
| Element | What it is for |
|---|---|
time | A date or time that machines can read, using datetime |
progress and meter | A task's progress, and a measurement within a known range |
output | The result of a calculation or an action |
mark | Text highlighted because it is relevant right now, such as a search match |
data | A human-readable value with a machine-readable value |
Coming Soon, or Only in Some Browsersβ
New ideas often appear first in a single browser. When only one browser supports a feature, treat it as experimental:
- Do not build important parts of a page on it.
- Use it as a small enhancement, if it degrades gracefully.
- Watch its support and Baseline label, and come back later.
The Readiness Judge tab turns this into a simple decision tool. Try the combinations, and see how the advice changes.
A Quick Way to Learn Any New Featureβ
- Read the top of its MDN page. What does it do, in one sentence?
- Open the compatibility table, and find the Baseline label.
- Build a tiny test page with only that feature.
- Test with the keyboard, and in a second browser, and on a phone if you can.
- Decide the fallback, using the Readiness Judge.
- Add a short comment in your code with the feature name and the date you checked.
- Re-check from time to time, as support grows.
Checking Your Setupβ
- On MDN, open each feature you use, and check its Baseline label and compatibility table.
- Use DevTools' device mode to approximate a phone, and a real phone to see the real keyboard.
- Turn the feature off in your head: if it were missing, would the page still work?
- Open the Console for warnings about unknown attributes or blocked scripts.
- Test with a screen reader or at least the keyboard, for
search,hidden, and any form changes.
Best Practicesβ
- Use new features as enhancements on top of a working page.
- Check support on MDN or Baseline before relying on a feature.
- Use
inputmodefor codes, instead oftype="number". - Put
fetchpriority="high"on one image, the likely LCP element. - Mark brand names and code with
translate="no". - Prefer
detailsoverhidden="until-found"for important content. - Keep
forminsidesearch, and addrole="search"to forms for older browsers if needed. - Order import maps first, and allow them in your CSP.
- Comment the date you checked support.
- Re-check old decisions when browsers update.
Quick Checklistβ
- Each new feature is an enhancement, or has a fallback
- I checked each feature's Baseline label and compatibility table
- Code fields use
inputmodeandpattern, with server-side checks - At most one image has
fetchpriority="high" - Brand names and code snippets have
translate="no" - No important content depends on
hidden="until-found" - Import maps come before the module scripts that use them, and fit my CSP
- I tested the keyboard path and a second browser
Security and Privacy Notesβ
inputmodeandpatternare not validation. A visitor can send anything. The server must check every value. See Secure Forms.- Module scripts follow the same rules as other scripts. Only load them from places you trust, use
https, and keep your CSP in mind. hiddenhides, it does not protect. Anything in the HTML is sent to every visitor and is readable in the page source. Never hide private information that way.translateand page translators: a translator sends text to a translation service. Mark text such as personal data and codes withtranslate="no", and do not paste private pages into online translators.
Global Audience Notesβ
translate="no"protects brand names and technical terms when visitors use their browser's translation, which is common worldwide.- Keyboards and input methods differ. Many people type with an input method editor for languages such as Chinese, Japanese, and Korean. Avoid code that breaks as people compose characters, and use
inputmodeonly where it truly helps. - Number formats differ. Decimal marks, digit shapes, and grouping vary, so accept more than you display.
- Older and low-cost phones are common. A feature that fails quietly is better than one that breaks the page.
Common Mistakes to Avoidβ
- Adopting a feature without checking support.
- Building critical content on something only one browser supports.
- Using
type="number"for codes, instead ofinputmode. - Giving
fetchpriority="high"to many images. - Hiding essential content with
hidden="until-found". - Placing the import map after the module that needs it.
- Forgetting the CSP for inline import maps and modules.
- Using
searchfor anything that is not search. - Treating hints as guarantees.
- Never re-checking after browsers change.
Practice Timeβ
- Complete the Feature Matcher. Which ones did you already know?
- In the Readiness Judge, set "Only some browsers" and "A mix". What does it say with and without graceful fallback?
- Change the audience to "Some must use very old browsers", keep the same feature status, and compare.
- Pick a page of yours. Which of these features would help?
- Replace a
type="number"field for a postal code withtype="text"andinputmode="numeric". - Add
translate="no"to your site's name, and test with your browser's translate feature. - Pick your LCP image, and add
fetchpriority="high"to it only. Measure the change if you can. - Bonus: look up the Baseline label for
searchandhidden="until-found"on MDN.
Quick Recapβ
Click a question to check your answer.
1. What is the search element for?
It marks a part of the page as a search landmark, so assistive technology can jump to it. Put a form inside it.
2. Why use inputmode instead of type="number" for a code?
type="number" adds spinners, can change on scroll, and drops leading zeros. inputmode="numeric" only shows a numeric keyboard.
3. What does fetchpriority="high" do?
It hints that a resource, usually your main image, should be fetched earlier than others. Use it on one important image.
4. What is hidden="until-found" for, and what is its risk?
It keeps content hidden until find-in-page or a link fragment matches it. Where it is not supported, the content stays hidden, so avoid it for essential content.
5. Why use translate="no"?
It stops page translators from changing brand names, code, and codes, which they would otherwise translate.
6. How do you judge whether a feature is ready?
Check its Baseline label and compatibility table, think about your visitors, and ask whether the page still works without it. If it does, use it as an enhancement.
Key Takeawaysβ
- Most modern features are hints and improvements. Add them to a solid base.
search,inputmode,enterkeyhint,fetchpriority,decoding,translate, andspellcheckare small changes with real benefits.hidden="until-found"needs care, because missing support hides content.- Modules and import maps are the modern way to organise scripts, and still obey your CSP.
- Check support, decide the fallback, and test.
- Hints are not validation or security. The server still checks everything.
Next up: Dialog, where you will learn how the built-in modal dialog handles focus, layering, and the Escape key for you.