Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

This question already has an answer here:

How to write code in a question/answer on a Stack Exchange site?

share|improve this question

migrated from Apr 22 '11 at 21:47

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Shadow Wizard discussion Dec 25 '15 at 19:47

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.

Before and after your code block press the ` (backtick) key followed by a blank space.

(Note: Do not mistake Backtick character and key ` with apostrophe character and key ') Thanks to @middaparka for the advice

Backtick key is here on most english keyboards:
backtick key

code block

(see Markdown Editing Help page)

share|improve this answer
This is a comment to show you that backtick key to mark inline code spans work on comments too: println('It works on comments too!'); – Francisco Alvarado Apr 22 '11 at 22:03
And all my life I've been prepending every single line with 4 spaces – floribon May 17 at 13:52

Above the text box there is a button with curly braces. Mark your code and push that button.

share|improve this answer
YES! I've been looking for this! – T.J. Feb 23 '12 at 16:18

If you add four spaces before a line, it will become code. Otherwise you can copy and paste your code into the text box. Select it, then press the {} button at the top of the form to turn it into code.

share|improve this answer

It tells you on the right side when you are writing the question. I believe it is 4 spaces in front of each line of code.

share|improve this answer

Put it within backticks or indent the lines with four spaces. This information is clearly provided to you when you go to the post-a-question link.

share|improve this answer
You need to use a backtick (`), not an apostrophe / "single quote". :-) – middaparka Apr 22 '11 at 21:48
Fixed, thank you! – chandsie Apr 22 '11 at 21:50