There are several issues with using <pre>
for formatting code. In particular, things that look like html tags become such. <iostream>
doesn't format right at all when within a code block.
Furthermore, the code isn't syntax highlighted when in a <pre>
block. Note the syntax highlighting here using the four space indent (and a hint that it is C since its not tagged that way):
#include <iostream>
int main()
{
std::cout << "Hello, world!\n";
return 0;
}
There are very few use cases where one would desire to use a <pre>
block to identify code (though I'm open to being corrected here).
And just for 'fun', since it messes up the formatting, this is what the code gets when wrapped in <pre><code>
tags:
#include
int main()
{
std::cout
Yep, its all there, though its still problematic.
Additional back ticks cause problems when trying to show you that <iostream> isn't showing up in that code block. The source for the first revision of this post can be seen at https://meta.stackoverflow.com/revisions/02b3d1c8-ffed-4453-91b7-aac8e3d033e8/view-source
<code>text</code>
is equivalent to`text`
(producingtext
) and<pre>text</pre>
is equivelant to: text
(on a new line; without the colon (formatting stupidity)). If you use both it's unnecessary. (For what you are doing, you only want<pre>text</pre>
.