Към основното съдържание
← 📄 HTML & the platform·Модул A2 · Урок 9
ЗадачаBuild an FAQ with two details elements. Each has a <summary> question and a <p> answer. Questions: 'Is it free?' / 'Yes, the first 15 lessons.' and 'Need to install Python?' / 'No — runs in your browser.'

<подробности> и <резюме>: собствени сгъваеми

75 XP6 min
Теория

Browsers ship a free accordion widget

<details>
  <summary>Click to expand</summary>
  <p>Hidden content. Toggles on click. Keyboard-accessible.</p>
</details>

That's the entire feature. No JS. No framework. No event listeners. Works on every browser.

Open by default

<details open>
  <summary>This starts expanded</summary>
  <p>…</p>
</details>

Common uses

  • FAQ entries — clean, accessible, semantic.
  • "Show more" buttons — for long content sections.
  • Code-listing toggles — collapse the boilerplate.
  • Disclaimer / Terms — collapsed by default.

Style the marker

The default disclosure triangle is browser-specific (▶ → ▼ on most). Hide and replace:

summary {
  list-style: none;       /* Firefox + Chrome */
  cursor: pointer;
}
summary::-webkit-details-marker { display: none; }   /* Safari */
summary::before { content: "+"; margin-right: 8px; }
details[open] summary::before { content: "−"; }

NOT a modal

<details> collapses inline. For a modal that overlays the page, use <dialog> (next lesson) — different tag for a different job.

🔒

Регистрирай се за да започнеш да кодираш

Теорията е отворена за всички. Редакторът, живият преглед и проверката се отключват с 7-дневен безплатен пробен период — нужна е карта.

Регистрация — безплатен пробен период →

Първите 10 урока във всеки път са безплатни. Без карта.

← НазадСледващ урок →

Един съвет за Python или уеб на ден — на имейл

Кратко, ръчно написано, без спам. Отписване с едно кликване.