Skip to content

Commit aaddc35

Browse files
committed
Add Disclose Additional Details as an HTML TIL
1 parent b575534 commit aaddc35

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
1212

13-
_1559 TILs and counting..._
13+
_1560 TILs and counting..._
1414

1515
See some of the other learning resources I work on:
1616
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
@@ -454,6 +454,7 @@ See some of the other learning resources I work on:
454454
- [Adding Alt Text To An Image](html/adding-alt-text-to-an-image.md)
455455
- [Determine Which Button Submitted The Form](html/determine-which-button-submitted-the-form.md)
456456
- [Disable Auto-Completion For A Form Input](html/disable-auto-completion-for-a-form-input.md)
457+
- [Disclose Additional Details](html/disclose-additional-details.md)
457458
- [Make Elements Non-Interactive With Inert](html/make-elements-non-interactive-with-inert.md)
458459
- [Prevent Search Engines From Indexing A Page](html/prevent-search-engines-from-indexing-a-page.md)
459460
- [Render Text As Superscript](html/render-text-as-superscript.md)

html/disclose-additional-details.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Disclose Additional Details
2+
3+
You can add extra details to an HTML page that are only disclosed if the user
4+
chooses to disclose them. To do that, we use the `<details>` tag. This tag
5+
needs to have a `<summary>` tag nested within it. Anything else nested within
6+
`<details>` will be what is disclosed when it is toggled open. The `<summary>`
7+
is what is displayed when it is not open.
8+
9+
Here is a `<detail>` block I recently added to [Ruby Operator
10+
Lookup](https://www.visualmode.dev/ruby-operators).
11+
12+
```html
13+
<details className="pt-2 pb-6">
14+
<summary>What is this thing?</summary>
15+
<p className="pl-3 pt-2 text-gray-700 text-sm">
16+
Ruby is an expressive, versatile, and flexible dynamic programming language. That means there are all kinds of syntax features, operators, and symbols we can encounter that might look unfamiliar and are hard to look up. Ruby Operator Lookup is a directory of all these language features.
17+
</p>
18+
<p className="pl-3 pt-2 text-gray-700 text-sm">
19+
Use the search bar to narrow down the results. Then click on a button for the operator or symbol you want to explore further.
20+
</p>
21+
</details>
22+
```
23+
24+
On page load, the only thing we see is "What is this thing?" with a triangle
25+
symbol next to it. If we click the summary, then the entire details block
26+
(those two `<p>` tags) are disclosed.
27+
28+
[source](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details)

0 commit comments

Comments
 (0)