This question already has an answer here:

I stumbled across this question: Vertical align span text inside inline-block div and noted that the question itself could be improved to use code snippets -- as you can see I have done.

However, thinking for feng-shui purposes that the accepted answer (which links to js-fiddle) would also benefit, I realised a problem. The answer had provided example code which highlighted the salient points of the answer, without providing the complete code (which I found to be a fab' way to answer).

So, if I were to edit the answer to use code snippets, the answer would get ugly, with lots of irrelevant bits of code.

It would be nice to be able to have a 5th (!!) area in the edit code snippet such that you can specify a 'summary' of the code. Alternatively, a checkbox on css/html/js to 'hide' that part of the snippet from the answer.

What do you think?

marked as duplicate by Kevin Brown, IronMan84, Alexis King, Unihedron, Mureinik Feb 12 '15 at 6:36



Runnable code snippets are often called Stack Snippets, which is what I refer to them as.

I agree that it would useful to have a way to hide code in Stack Snippets, but I see this opening the door to abuse. You are hiding parts of the code from future readers, which could be really unexpected if someone was looking at the code and expecting everything.

To quote a better answer from Allow to hide sections of Stack Snippets by Shog9:

At best, such behavior would break the assumption that snippets are self-contained solutions - if you think you're seeing everything needed to accomplish a task while in fact key elements are hidden, confusion will result.

Stack Snippets were introduced as a common feature request for runnable code snippets. You can find the introduction post at Feedback requested: Runnable code snippets in questions and answers.

The key part there is that they should be used for runnable code snippets. This makes them incredibly useful for demonstrating full HTML/JavaScript questions and answers, giving you the ability to demonstrate the problem and solution. They are meant to replace plain code blocks in those cases, and should not be used unless the snippets are runnable.

There is no use in demonstrating only parts of a code, when you need the full code for it to run.

  • I completely agree, except for the notion that you need the complete code. Doesn't printf("hello world"); reveal enough information without needing to also supply int main() { ... }? If you look at the two answers given in the post I linked to, both give just enough code to highlight where the solution lies. Both also link to a fully working demonstration. In my mind, this is the best of both worlds: short and succinct answers, but with complete working demo code. I don't see either of the answers given in my example post to be confusing in the slightest. – cmroanirgo Feb 12 '15 at 6:57

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