use PRE tags

When publishing code or some text that needs a strict syntax (in an article, a forum message, a tip, whatever) ALWAYS use the appropriate tags, which is either CODE tags (for a small snippet, no more than one line) or PRE tags (for all multi-line snippets).

The overall advantage is better readability, and as a result reaching a broader audience and getting more and better feedback. In detail:

CODE and PRE tags result in a non-proportional font, which preserves indentation;

PRE tags give a nice background color, very good for contrast;

CODE and PRE tags perform syntax coloring, assuming you add a LANG=”some language code” to the opening tag; unfortunately without the change in background, such coloring makes CODE completely unreadable; so PLEASE set LANG=NONE for every snippet in CODE tags. For PRE tags too, the default is LANG=CPP even in the C# and VB forums; so you really should add LANG=CS or LANG=VB to get the keywords recognized correctly.

As this is simple and very effective, I can tell you I simply no longer read code that is not tagged appropriately; if the author doesn’t care, neither do I.

Here is an example (with the PRE tags shown):

<pre lang="cs">
private void demoMethod(int arg1, int arg2) {
    return arg1*arg2;
}
</pre>