<details> element
This is a standard <details> element. Pressing the <summary> opens the hidden content.
<p> This is my secret hidden information! </p>
This is my <summary>!
This is my secret hidden information!
Adding "open" to the <details> element tells the browser to load the dropdown as already open.
<p> This information is NOT secret. </p>
<details>
<p> This information IS secret. </p>
This <details> element starts as open.
This information is NOT secret.
This <details> element starts as closed.
This information IS secret.
Dropdowns with name="exclusive" in the element will close all other dropdowns when it is opened.
<p> This information is NOT secret. </p>
<details name="exclusive">
<p> This information IS secret. </p>
This <details> element starts as open.
This information is NOT secret.
This <details> element starts as closed.
This information IS secret.
We can add CSS to <details> just like any other element. Let's add a {background-color}, and use the [open] attribute selector to change colors when it opens.
details[open] {
This is my <summary>!
This is my secret hidden information!
We can use pseudo-classes like ::after to adjust content with the [open] attribute selector.
<p> This is my secret hidden information! </p>
details[open] summary::after {
Click here to
This is my secret hidden information!
We also target the little arrow, a.k.a the marker. You can change the color, remove it entirely, or replace it with a custom emoji! With details[open] we can change the marker as it opens or closes.
<p> This is my secret hidden information! </p>
details[open] summary::marker {
This is my summary!
This is my secret hidden information!