liveBook · Manning

Accordion

As explained in Build a Website with ChatGPT

An accordion is an interactive HTML element that shows an item’s summary and can expand to reveal or hide its associated content.

An accordion shows a short summary and lets visitors expand it to reveal associated content, then hide that content again. section 5.2.1

An HTML accordion has two parts:

  • The summary is the visible title or description. section 5.2.1
  • The details contain the summary and the rest of the content, such as text or images. section 5.2.1

In an online journal, each post can be an accordion: visitors initially see its title and can open it to read the entry. This lets a page hold several posts without overwhelming visitors with content. section 5.2.1

Include a main section where each entry is an accordion using the HTML summary and details elements. For each entry, the summary text is the entry title and the details include the entry date, followed by the entry text. Please provide four sample entries going back four days from today.

A sample prompt asks for journal entries whose summaries are titles and whose details contain dates and entry text. section 5.2.1

How Build a Website with ChatGPT covers it

How deep it goes
Defines summary and details and explains toggling, while leaving HTML and CSS implementation details to generated code.
Examples
Uses journal posts with a title, date, and entry text, plus a prompt requesting four sample entries.
What it assumes
Introduces summary and details before prompting and supports requesting generated code without knowing how to code.
What you can do after
Apply it via ChatGPT by requesting journal entries built from HTML summary and details elements.
How it connects
Connects HTML summary and details elements with CSS styling and online journal pages.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Website with ChatGPT. The section links point to the parts of the book it draws on.