2

I've been trying to use the <blockquote> tag to include literal output in this forum, but I cannot get it to work for me. My understanding is that if a chunk of text is surrounded by the <blockquote> and </blockquote> tags, then newlines within that chunk will be preserved. But that doesn't seem to be happening.

2
  • 1
    Only a small portion of HTML is supported, I would suggest you use markdown instead of HTML for formatting your post
    – Thomas Ward Mod
    Jan 8 at 19:36
  • 1
    Please see askubuntu.com/help/formatting for details on the markdown specification supported by thee sites.
    – terdon
    Jan 9 at 11:33
3

You don't need HTML. Instead, to make a blockquote, use the > character. Remember to have a blank line after the end of the blockquote. Here's an example:

> Ask Ubuntu is amazing!

Here's how that will render

Ask Ubuntu is amazing!

And using multiple lines:

> Ask Ubuntu is amazing!
>
> Unix SE is very good, too!

And here is how that will render

Ask Ubuntu is amazing!

Unix SE is very good, too!

If you really want to use HTML instead of Markdown, you can. Here's how:

<blockquote>
Ask Ubuntu is amazing!
Unix SE is great, too!
</blockquote>

Remember to have a blank line after </blockquote> or strange things can happen.

And that will render as this:

Ask Ubuntu is amazing! Unix SE is great, too!

You mentioned it isn't making a newline. You have to have an entire blank line if you want a linebreak, like this:

<blockquote>
Ask Ubuntu is amazing!

Unix SE is great, too!
</blockquote>

And that will render as this (with the newline as desired). For the Markdown version, just include a > on a line by itself to indicate a line break.

Ask Ubuntu is amazing!

Unix SE is great, too!

For the rest of the valid HTML tags on SE, see this Meta SE post


However, for command output (or code), don't use blockquotes. Instead, use a codeblock, and you start end end those with three backticks (```). Here's an example (you can optionally include a language, like C or Python, after the three backticks if you want, for syntax highlighting)

```c
int main()
{
    printf("Hello World");
    return 0;
}
```

That will render like this:

int main()
{
    printf("Hello World");
    return 0;
}

If you're wondering why you have to include an entire blank line (or, in the Markdown version, add a > on a line by itself), check out this Stack Overflow question that includes the reasons.

2
  • 1
    Now that I've rediscovered ```, I have no need for anything else.
    – Paul A.
    Jan 8 at 23:29
  • <pre> and </pre> is more visual IMO.
    – Hannu
    Jan 9 at 9:52
2

Blockquote formatting does not preserve line breaks, which is why it should not be used to format output from a command - long output becomes horribly unreadable, and since blockquoted text, unlike unformatted text, also loses the original line breaks from the markdown text, it is impossible to fix the problem by editing!

Use code formatting to preserve line breaks in output from a terminal or code, or if the text is actually a quote rather than code(like text) and for some reason you really need to preserve the line breaks, you can insert line breaks as needed by putting two spaces and then a newline, though I rarely find any need to do so.

You must log in to answer this question.

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