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 is an interactive HTML feature that keeps an item compact until someone opens it. It has a summary, which acts as the visible title or description, inside details, which holds the summary plus the rest of the content. Clicking the summary toggles the detailed content between hidden and displayed. section 5.2.1 section 5.5

Accordions work well for pages with many journal entries: visitors can scan entry titles first, then open only the posts they want to read. A closed item shows its summary; an open item shows its full contents. section 5.2.1

Journal entry structure

Use one details element per entry. Put the entry title in summary, then place its date and text after the summary. To add another entry manually, copy an existing details block, paste it where you want the new entry, and edit the title, date, and text. section 5.4 section 5.4

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.

This prompt requests four sample journal entries, each built with HTML summary and details elements so the title stays visible while the entry content can be expanded. section 5.2.1

When asking ChatGPT to create a journal page, specify that each main-page entry should be an accordion. Include what belongs in each part: the title as summary text, followed by the date and entry text in details. ChatGPT can generate the HTML and CSS; small changes can then be made directly in the files. section 5.2.3 section 5.4

How Build a Website with ChatGPT covers it

How deep it goes
Defines summary and details, explains click-to-toggle behavior, and gives prompting and copy-editing steps without deeper HTML internals.
Examples
Demonstrates four collapsed journal accordions and a details block containing a title, date, and multiple paragraphs.
What it assumes
Starts from no coding knowledge while introducing the summary and details elements needed immediately.
What you can do after
Build it from scratch by copying a details entry and editing its title, date, and text.
How it connects
Connects HTML summary and details elements with CSS, journal entries, and ChatGPT prompts.

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.