I am writing a chapter in an upcoming book that contains guidelines on creating accessible course content. Part of that is collapsible sections of text for ease of navigation and making long readings less intimidating.
This text is not visible when the section is collapsed. It will be recognizable to a screenreader, though. The code is executed like this:
<details> <summary>Title or summary goes here</summary> The body of the text goes here; for formatting you might use a <p> tag to define a paragraph. </details>
Closing tags is important
If you don’t close tags, you create nested content. Which can be useful for items like subsections or additional details like this, but is something you always want to be doing deliberately!