Finding text in hidden/collapsed containers in a web page

2 points by residualmind ↗ HN
This really annoys me.. You google for something on your phone and let's say a relevant Wikipedia article comes up, with your search already highlighted in Google's result list. You open that article and all you get is the nice, clean, all-collapsed view of the page with the occurrance your search term hidden from you. Ctrl-F'ing will get you only this far and you as a dev at this point probably resort to your favourite F12 dev tools to locate your prey...

Are there any ideas or solutions to this? Collapsed text paragraphs have become a very common pattern, but is there a (suggested) way of letting the browser know that tag <section /> is in its collapsed state and to expand it, for instance when the text search hits something within it, CSS class thisClass is to be set on the container or JS function thatFunction() is to be called?

Probably this is something too specific to consider in HTML in general, but it does happen an awful, annoying lot...

2 comments

[ 4.1 ms ] story [ 16.7 ms ] thread
Browsers should just stop recognizing "display: none" as a valid style attribute. "visibility: hidden" is another one.

If I had the skill to modify a browser this would be one of the first things to go.

As for your particular problem, if there is a clear space where some content should be, I resort to: right click -> Inspect Element with Firebug. I doubt there is a good way to reliably change styles across websites.

That's an important feature. "Display:none" hides the element completely whereas the "Visibility:hidden" hides the element but reserves the space that now hidden element used.

If you have a box with "Display:none" - the box is no longer there. Try it with "Visibility: hidden" - the box is no longer there but the shape of the box remains.

The problem has zero to do with CSS. Robots have no concept of styling when crawling. It's the way the URI's are interpreted. You're jumping from one server to another server. If Google placed a parameter in the URI or designated a cookie/session that you could interpret, you could pull the search term and do what you will with it.

However, Google only suggest the page based on contents of that page. Not the article and section it was found in.