A standard spoiler / content-warning mechanism
Nobody has claimed this yet.
- Dominant language
- MDX
- Stars
- 4.5k
- Forks
- 226
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 4
Description
A spoiler / content-warning mechanism is used to hide content not all readers may wish to read or at least not yet. In addition to spoilers and content warnings, this can be used to tag the answer to a question in a tutorial or on study site to let the reader attempt to solve it themselves before checking their work. For brevity, I will only refer to this as spoilers from now on.
This is a common pattern for community-oriented sites. It is a common enough pattern to have a section on wikipedia, for whatever that's worth: https://en.wikipedia.org/wiki/Spoiler_(media)#Website_policies_and_features
A spoiler is open or closed and user interaction toggles this state. A closed spoiler obscures (but does not collapse) its children. Generally this is by making it all black to resemble redacted text though sometimes a heavy background-blur is used for spoilered images. When closed its obscured content is inert. Sometimes there is a reason provided to tag book vs. movie spoilers or to explain the nature of the content warning to let the reader decide.
This should be standardized for two reasons
- how these work differ between sites and regularity would help users
- there are many subtleties in implementation, especially surrounding accessibility, that are difficult to get right if even if there is even an attempt to do so.
There are three paths to standardization
- adding various facilities to make these patterns easier to implement
- adding a
content-warningattribute (per @aarongustafson ) - adding a
<spoiler>tag
details/summary immediately comes up in all previous discussions but does not work for a multitude of reasons:
where details/summary fails
- It is a block level element so it cannot be used to spoiler inline text. Even with
display: inlinethe use of a details tag will autoclose the enclosing paragraph. It's common practice to spoil in a paragraph or even within a sentence. - Chrome (correctly) opens details if find-in-page matches, which is something that you do not want to happen with spoilers.
- The element (currently) cannot be styled in a way that matches user expectations.
Previously
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the issue's discussion of details/summary and the linked WICG and WebWeWant discussions. Compare the three proposed standardization paths, focusing on inline use, inert closed content, find-in-page behavior, styling, and accessibility; done means one approach and its requirements are agreed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html
- Domain
- accessibility, frontend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100