59

How do I do a single newline/carriage return when typing a question or answer?

For example, if I wanted to write some columns with values as in an Excel spreadsheet. I see people do it all the time, but I don't know how. I read the formatting tips and all about the blockquote stuff... did some google'ing, but I still haven't found out how.

The only way I know to do newlines is by pressing the Enter key twice, which makes a new paragraph, creating an empty line, which is not what I want.

9
  • 4
    Did you already try <br/> like in HTML? Commented Jun 20, 2012 at 12:27
  • Thanks Tim. <br/> works ! I didn't think of that one. I can use shift+enter here for newlines, but when asking a question or answering one I have to use <br/> tags. Okay. got it. edit: You can put that solution in as an answer so it can be voted on. Respectfully, Josh Commented Jun 20, 2012 at 12:33
  • I find that sometimes <br> is needed too, depending on the situation Commented Jun 20, 2012 at 12:42
  • So it looks like that meta part of the site deals with questions pertaining to mechanics of the stackoverflow site itself. Please correct me if it is anything different or anything more. Commented Jun 21, 2012 at 19:47
  • 1
    Beware of the small screens, where such tables do not have scrollbars but are wrapped. Commented Jul 5, 2012 at 16:51
  • 1
    Related: balpha wrote a long answer to a related question explaining why the two-line rule exists. Commented Sep 20, 2012 at 17:28
  • 3
    hit Spacebar twice. then Enter Commented Sep 20, 2012 at 17:59
  • 1
    As u useful comment was wiped when other answers to this question were deleted, let me repeat one very good reason not to use <br>: <br/> creates formatting messes later for someone trying to go back and edit to clean up other things (say, by applying a <pre> tag -- suddenly all that markup is visible), and it's the harder way to do this anyway. – Joel Coehoorn♦ Jul 5 '12 at 16:05 Commented Aug 17, 2013 at 8:24
  • I found <h6></h6> helpful as it generates a blank space for a heading, without any text. This is not just for a new line but also for some space after the newline which looks aesthetically more beautiful. Commented Apr 11, 2024 at 8:18

2 Answers 2

82

You can type two spaces    and press Enter.
Like so.

I wanted to write some columns with values as in an Excel spreadsheet

For longer/pasted text, you can also format as code in many ways, like by indenting with 4 spaces, or by using <pre></pre> tags (which need manual encoding of HTML), like so:

 Column 1 Column 2 Column 3 value 1 13 26 value 2 11 22 
9
  • 6
    But as an aside: line breaks should not be confused with (or abused for) paragraphs. Commented Jul 25, 2012 at 9:34
  • 2
    @gobernador, Why not use <br> instead? Commented Apr 5, 2015 at 11:29
  • Is that useful? of no use Commented Apr 30, 2015 at 5:40
  • @kdh, I mean typing <br> instead of typing "space" + "space" + "newline". Try it, it works. Commented Jul 15, 2015 at 1:42
  • @Pacerier as Pops said in a comment to a now deleted answer, "Markdown should be preferred over HTML" - which makes sense. Raw HTML should be used with care and only when there's no Markdown alternative. Commented Jul 15, 2015 at 7:30
  • @ShadowWizard, That's true only if a future CSS template might display them differently. However, <br> and "space" + "space" + "newline" are synonymous regardless of styling. Commented Aug 5, 2015 at 9:22
  • testing the new line now <br> my new line Commented Jun 6, 2017 at 5:54
  • test<br> it works really ? Commented Sep 28, 2017 at 6:37
  • @jitenshah: HTML tags don't work in comments, only in posts. There's no way that I know of to insert line breaks in comments (except for MathJax hacks on sites that have it enabled). Commented Oct 31, 2017 at 19:24
7

Use the HTML line break tag '<br>'. See the example below where Line 1 uses the line break and line 2 uses the Enter key.

Example (1: <br>, 2: Enter)

Line 1
Line 2 Line 3


Click the Edit button on this post here for good reference.

3
  • 1
    That works, but there are already three deleted answers suggesting that, all with negative scores. People don't like HTML when there's a Markdown solution :) Commented Oct 31, 2017 at 18:44
  • The two spaces + enter is a lot more elegant, especially in markdown view. I'm sure there's times (and spaces) for html, but doublespacing what I recommend. Commented Nov 1, 2017 at 2:57
  • 2
    For me, this answer is useful. Commented Feb 22, 2019 at 7:28

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.