The devil is in the details…

It is not that hard to create a script that shows and hides parts of the document, but often we forget about how our visitors use the products we build. Especially when it comes to navigating huge documents, people tend to use the “find in page” functionality of browsers. And when they do and we […]


This content originally appeared on Christian Heilmann and was authored by Chris Heilmann

It is not that hard to create a script that shows and hides parts of the document, but often we forget about how our visitors use the products we build. Especially when it comes to navigating huge documents, people tend to use the “find in page” functionality of browsers. And when they do and we hid content with JavaScript, browsers would either not find the content or users won’t know where in the document it is.

If you use the HTML elements of summary and details you don’t have to write any show/hide code yourself and users of Chromium browsers (Edge, Chrome, Brave…) can use “find in page” as the browser will automatically expand the details that contain their search terms.

Here’s a quick video showing that on The VS Code YouTube channel and on TikTok .

You can see this in action on any page that uses the elements. For example on this W3C document you can open the Developer Tools and see the browser add the “open” attribute to the detail in question when the term was found inside the details.

Animation of the browser automatically opening a section when a search term was found inside it.

More about summary and details:


This content originally appeared on Christian Heilmann and was authored by Chris Heilmann


Print Share Comment Cite Upload Translate Updates
APA

Chris Heilmann | Sciencx (2022-04-05T11:22:56+00:00) The devil is in the details…. Retrieved from https://www.scien.cx/2022/04/05/the-devil-is-in-the-details/

MLA
" » The devil is in the details…." Chris Heilmann | Sciencx - Tuesday April 5, 2022, https://www.scien.cx/2022/04/05/the-devil-is-in-the-details/
HARVARD
Chris Heilmann | Sciencx Tuesday April 5, 2022 » The devil is in the details…., viewed ,<https://www.scien.cx/2022/04/05/the-devil-is-in-the-details/>
VANCOUVER
Chris Heilmann | Sciencx - » The devil is in the details…. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/05/the-devil-is-in-the-details/
CHICAGO
" » The devil is in the details…." Chris Heilmann | Sciencx - Accessed . https://www.scien.cx/2022/04/05/the-devil-is-in-the-details/
IEEE
" » The devil is in the details…." Chris Heilmann | Sciencx [Online]. Available: https://www.scien.cx/2022/04/05/the-devil-is-in-the-details/. [Accessed: ]
rf:citation
» The devil is in the details… | Chris Heilmann | Sciencx | https://www.scien.cx/2022/04/05/the-devil-is-in-the-details/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.