Content the browser hides
Some HTML is in the file but not on the screen until something shows it. hidden, <template>, a closed <dialog> and <noscript> all hide content in different ways.
Step by step
- By default,
hiddenhides an element; removing the attribute shows it again. - A normal
<template>holds HTML that is not shown; scripts can copy it into the page. - By default, a
<dialog>stays hidden until it hasopenor a script opens it. - Sending a
<form method="dialog">inside a dialog closes the dialog instead of sending data. <noscript>content is shown only to visitors who have JavaScript turned off.
The card, bug marked
1<section id="newsletter">
2 <h2>Newsletter</h2>
3 <p>New lessons every month.</p>
4 <p id="thanks" hiden>
5 Thanks! Check your inbox.
6 </p>
7</section>
This is how it's right
<p id="thanks" hidden>Thanks!</p>
<template id="gig-row">
<li>Band A</li>
</template>
<dialog open>
<form method="dialog">
<button>OK</button>
</form>
</dialog>
<noscript><p>Turn on JavaScript.</p></noscript>
Exercises for this topic
Key rule
Hidden content is still in the file, so check which attribute or tag hides it and what is meant to show it.
Where you'll meet this
You meet these in sign-up forms, pop-up messages and lists that scripts fill in. <noscript> often holds a fallback message for visitors without JavaScript.