I've posted a few questions with code on this site. Each time I have written the code with appropriate line-breaks. But when I post the questions the line-breaks disappear, and all the code ends up on one line. Then someone usually comes along and needs to edit the code in my questions to add the line-breaks.

What am I doing wrong? How do I create line-breaks in my questions that will stay there once I post?


2 Answers 2


You can find formatting information in the Markdown Editing Help page of the Help Centre.

That page can also be reached by clicking the help symbol in the editing toolbar:

editing toolbar with help highlighted

To format a block of text as code, select the text and hit CTRL+K or tap the braces icon in the editing toolbar:

editing toolbar with code formatting icon highlighted

Alternatively, surround the text with three backticks ("code fences") on separate lines:


This is rendered as code
Line breaks are preserved

Renders as:

This is rendered as code
Line breaks are preserved
  • Very clear explanation. Thank you.
    – Jimbo
    Commented Jan 13, 2023 at 13:15

Taken from the small question mark at the top of the input field where there command buttons are situated:

To create preformatted text, indent by four spaces or surround with groups of backticks:

This will be displayed in a monospaced font. The first four spaces will be stripped off, but all other whitespace will be preserved.
Markdown and HTML are turned off in code blocks:
<i>This is not italic</i>, and [this is not a link](https://example.com)

To create not a block, but an inline code span, use backticks:

The $ character is just a shortcut for window.jQuery.

If you want to have a preformatted block within a list, indent by eight spaces:

  1. This is normal text.

  2. So is this, but now follows a code block:

     Skip a line and indent eight spaces.
     That's four spaces for the list
     and four to trigger the code block.

Adding a language tag to the quoted/backticked code can be achieved like this:


...which will be displayed as:


On Stackexchange code is normally formatted according to the tags and on DBA.SE mostly as lang-sql, but there may be reasons to use different preformatted text, by overriding the default. A list of supported languages for code formatting can be found in the Q&A What is syntax highlighting and how does it work? (Meta Stackexchange)

Often you might see a combination of quoted and pre-formatted text to display error messages:

This is achieved by adding a > sign followed by 5 spaces and then your text.

Hope this helps.

You must log in to answer this question.

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