On July 16, 2021, I learned...

Content inside a `details` element is excluded from in-page search

It makes total sense, of course: if content is on the page but isn’t actually showing on the page, then there’s no need to show when searching content. That’s what I assumed it would do, but know for sure after testing in the major browsers.

Search me! The quick brown fox jumped lazily over the big brown dog. Or something like that. ????

To be clear, once the details panel is open, search will indeed pick up the text inside. I can see justification for allowing the text to be searched in the closed state as well. It’s one of those things that you sorta have to draw a line in the sand for, and it seems all browsers have drawn the line at excluding hidden text.

In that sense, in-page search treats text inside a details element the same as text that’s hidden with display: none.


Leave a Reply

Markdown supported