html · level 3 · unit 6 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
<details> and <summary> make a that opens and closes.
A widget is a ready-made control people use, like a button. <details> is a widget built into HTML. The browser shows only its <summary>, with a small triangle. Click it and the rest appears. Click again and it hides.
<summary> must be the first thing inside <details>. Everything after it stays hidden until opened. Add the open attribute to start it open.
Give several <details> the same name and they become an : opening one closes the others. It all works with the keyboard and with screen readers, and needs no script.
<h2>Questions</h2>
<details name="faq" open>
<summary>Do you deliver?</summary>
<p>Yes, anywhere in Leeds, and free over £30.</p>
</details>
<details name="faq">
<summary>Can I return a plant?</summary>
<p>Within 14 days, if it is still alive.</p>
</details> Press show my page to see it here.
open needs no value. Writing it at all is enough.
guess first
What shows before anyone clicks?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
<details>
<summary>What time does the gig start?</summary>
<p>Doors open at 7pm, and the band starts at 8pm.</p>
</details>
your turn
Your turn. Build an accordion.
Give both <details> the name faq, so only one opens at a time. Then fill the second blank on line 2 so the first one starts open.
Press show my page to see it here.
- both share the name faqnot checked yet
- one starts opennot checked yet
- the first one is the open onenot checked yet
fix it
The question says Details instead. Can you fix it?
Press show my page to see it here.
- the question is in a
<summary>not checked yet
- The browser shows its own word, Details, because it cannot find a summary. Why not?
- Look closely at the spelling of the tag on line 3.
- Change
<summery>and</summery>to<summary>and</summary>, then press run.
nailed it
your page opens and closes itself. :D
<details>hides everything after its<summary>.openstarts it open.- The same
nameturns a group into an accordion.
new words in your collection
- widget
- accordion
This lesson isn’t saved. A free account remembers every lesson you finish.