11

Without fail, every day I come across questions where the person has posted non-runnable code (e.g. CSS only, PHP only, ...), but instead of using the code formatting options of indenting or back ticking, they've found the code snippets button and just dropped their code in a snippet without understanding that that's not what it's intended for.

I'm happy that they've put the code into their question, but sad because they're using snippets when they should just be highlighting their code. And as a side effect, when they insert a snippet they add controls below their code that doesn't do anything: enter image description here

Can something be added to the system so that when a user embeds a snippet, a reminder pops up reminding them that it's intended for runnable JavaScript, CSS, and HTML code, and explain what we mean by runnable? Maybe a gentle reminder/warning similar to what was recently added to short, "try this" code answers:

enter image description here

Suggestion: When users add snippets to their question, prompts them with something like:

Code Snippets are for runnable JavaScript, CSS, and HTML code blocks. For other code:

  • Please use the backticks (The $ character is just a shortcut for window.jQuery.)
  • Indent each line by at least by four spaces:
  • Wrap your code in <pre> or <code> tags
  • Press Ctrl+K

For more information see https://stackoverflow.com/editing-help#code

4
  • 1
    Oh yes please!!! This is an epidemic among new users' PHP questions. Feb 6, 2015 at 18:58
  • 4
    Can something be done about users who use COMIC SANS?
    – user1228
    Feb 6, 2015 at 19:07
  • @Will asdfsdfasdfsaaddfaassdfdaasaddff Feb 6, 2015 at 19:10
  • I can appreciate that this question is similar to, or a dupe of, the other question, however that was nearly six months ago and nothing's been done, and this question offers a solution where the other question doesn't. To quote @Shog9 "There are probably things we can do to improve the guidance here, and I expect they'll become more obvious as more people find and use it"
    – j08691
    Feb 6, 2015 at 20:29

0

Browse other questions tagged .