This question already has an answer here:

Sometimes when writing answers on questions, I feel the need for a collapsible block of text or even code part.

The system already supports a lot of markup things like blockquotes, code snippets, headings, etc... And I think it would be a great improvement if we could make a collapsible block of text that has a label in it, something that would look like:

> <Label of text or code block> (click to expand)

And when you click it looks like:

v <Label of text or code block> (click to collapse)

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec egestas tellus et sapien luctus tristique vel id felis. Morbi non velit et elit gravida iaculis. In lacinia elit in sem porttitor et varius tellus egestas. Ut nibh nisi, adipiscing vel fermentum eget, dapibus a lorem. Integer fringilla lorem porta libero mattis quis aliquet neque tincidunt. Fusce cursus rutrum lacus, id porta odio condimentum eu. Proin suscipit lacus et mi ornare volutpat. Fusce eros lacus, tempor at facilisis vel, varius eget massa.

For a list of possible use cases:

  • Different parts of code can be collapsed. This can make the answer shorter if you need to view only one thing at a time. For example: an answer contains interleaved blocks of HTML, javascript and CSS. The author may only wish to see the HTML parts first and get them right. He collapses the CSS and javascript parts.

  • An answer may consist of the essential part that answers the question, and a further detailed explanation here and there. Not everyone will want to read those, but it makes the answer more complete.

  • The answer links to a resource, but we all know what link rot is. The user copies the most imporant parts in his answer, but that may be a lot of text, so he collapses it by default.

  • A question may contain details of which the OP is not sure they are important. Examples include: system specs on superuser, a list of the versions of frameworks/libraries used on SO, etc.

  • A lot of code may be contained in the question itself. Of course, I fully agree that the OP should do the best he can to limit the code to the parts that matter, but sometimes it's inevitable because of how it is structured. Then, the code may be split up into collapsible blocks. For example; one might collapse a method/function, where the label contains the method header or function definition.

  • Other Stack Exchange sites: These collapsible blocks may be used to hide spoilers. I think of Scifi, but also maybe code golf & programminging challenges, to give hints.

  • In general when a question is very long, it may discourage people to read it. Those collapsible blocks could make it more digestive, and will also allow answerers who are willing to read, to view different parts at a time to make it easier to solve a problem.

  • Other suggestions are welcome.

marked as duplicate by Adam Lear Apr 26 '13 at 20:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Questions should be written to help future visitors.

If I have a problem, I don't want a timeline of the investigation, using collapsed blocks or not.

I want psychic debugging—my vague description of the problem along with crucial details that I hadn't realized were important, but recognize as matching my situation.

Instead of:

I'm trying to frob the widget, but sometimes it hangs.

Edit: As commenters suggested testing, the hang does only happen immediately after booting.

Edit 2: I'm running Windows 95 on an abacus that I've trained a hamster to operate.

Edit 3: buxing does the same thign

Edit 3: The hamster's name is Gerald.

Edit 4: To answer @InsightfulCommenter, I'm using Edgar the Virus Hunter™ for anti-virus.

I want:

Widget hangs when buxed or frobbed immediately after booting. I'm using Edgar the Virus Hunter™.

When I search "widget hangs", I can then quickly see that you're describing my situation even though I hadn't realized that Edgar was involved.

So don't use collapsed blocks, just rewrite to keep any important bits and throw out everything else.

  • You have a good point about timelines, but that's not exactly what I meant either. I gave this as an example that it could apply to, but it could have other uses. – MarioDS Apr 26 '13 at 7:01
  • @MarioDeSchaepmeester If you have other ideas for how they could be used, I encourage you to add those to your question. There could be some awesome use-case that would make this a must-have feature, but I'm not seeing it right now. Listing more possibilities might find that cool use-case or help spark other good ideas. – blahdiblah Apr 26 '13 at 16:03
  • Thanks for the hint, I added a list of use cases I can think of. – MarioDS Apr 26 '13 at 18:30

I'm against this, for much the same reasons that I hate #regions in code.

  • If text is no longer relevant, why is it in the question? We have revision history for questions.
  • If the text is still relevant, but there's a lot of it -- then perhaps it should be pared down to its essentials?

Hiding the problem isn't going to solve it.

  • Sometimes it's not easy to determine when something is relevant or not. In my case I know what my own question is and how its changes progressed, but I was in doubt whether it would still be clear to users reading it for the first time. This may also have a use on SE sites where spoilers are a possibility in answers (or questions). And as a final point, voting happens based on what the question looks like in its current form. Not many people will care about the history, and if it happens to be unclear, they will probably not go and find out. – MarioDS Dec 5 '12 at 20:24
  • 4
    I also don't understand how you can hate #regions in code (or code-folds). If it is not used to hide code that is just unreadable of itself, it really helps with keeping a good overview. – MarioDS Dec 5 '12 at 20:27
  • 2
    +1; part of the process of getting your question answered is refining and improving the question; an important aspect of improving is taking out the irrelevant bits thereby keeping it readable and concise. Introducing "regions" in a sense would support the undesired behavior of keeping irrelevant information in the question. – Marijn Apr 25 '13 at 8:36
  • Glad I'm not the only one who hates #regions in code... – Adam Rackis Apr 26 '13 at 18:40
  • I added a list of more use cases, if you could, I would appreciate your opinion on those as well, and not only what I mentioned in the first version of my question. – MarioDS Apr 26 '13 at 18:41
  • 1
    @MarioDeSchaepmeester All of your use cases can be answered by my second bullet point: If there's a lot of text, it should be pared down to its absolute essentials. It's easy to write a lot of text. It's harder to get your message across in fewer words. We should be pushing people down the path of improving their writing, not excusing bad writing by allowing people to hide the problem. – George Stocker Apr 27 '13 at 13:08
  • @GeorgeStocker, just because you can’t think of a valid reason for it doesn’t mean there isn’t. Consider log files. Sometimes you must provide logs for analysis, and often they tend to be lengthy and cannot be pared down without losing potentially valuable information. Yet, there is no reason to have them be full-length by default. For example, someone may be able to diagnose an issue without even looking at it while others may need some clue from the log to figure out the problem. – Synetech Apr 21 '14 at 16:59
  • @Synetech Considering log files: Rarely is the entire log useful. There are useful snippets in a large log file; but those should be pulled out before the problem comes to us. That's part of the 'figuring out the problem' stage is to whittle down what you need to reproduce the issue to its bare minimum. – George Stocker Apr 21 '14 at 17:38
  • If someone knows what’s useful, they likely don’t need to ask. Also, large chunks of logs may be relevant, e.g., I posted the header to an email here and it’s unsightly. Not only is it long, it’s also a ghastly mess with lots of ugly characters cluttering the page. Having the first few lines visible by default would be better, then people can view more as necessary. Also, posted code can be long and ugly as well. There’s an upper limit to the height of the code block, but a collapsible block with a [Copy All] button would be better. – Synetech Apr 21 '14 at 19:26
  • (Oh, and posting to a third-party site like pastebin isn’t better.) – Synetech Apr 21 '14 at 19:27
  • 3
    Well this request looks reasonable now since the introduction of stack snippets. Lots of boilerplate code will be there in a snippet... – Tilwin Joy Oct 2 '14 at 15:00

Not the answer you're looking for? Browse other questions tagged .