Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Formatting Code in Tips and Tricks

0.00/5 (No votes)
8 Apr 2013 2  
Syntax coloring for tip/trick

Code in tip/trick posts should be wrapped with <pre> </pre> tags to ensure formatting and colouring are correct.

For example:

<pre lang = "vb">
' Example  
Dim test As String
</pre>

will produce:

' Example
Dim test As String

To specify the programming language, use lang="xxx" as follows:

<pre lang = "C++"> for native C++ formatting
<pre lang = "mc++"> for C++/CLI formatting
<pre lang = "aspnet"> for ASP.NET formatting
<pre lang = "cs"> for C# formatting
<pre lang = "css"> for CSS formatting
<pre lang = "F#"> for F# formatting
<pre lang = "html"> for HTML formatting
<pre lang = "Java"> for Java formatting
<pre lang = "jscript"> for JavaScript formatting
<pre lang = "asm"> for MASM/ASM formatting
<pre lang = "msil"> for MSIL formatting
<pre lang = "midl"> for MIDL formatting
<pre lang = "php"> for PHP formatting
<pre lang = "sql"> for SQL formatting
<pre lang = "vbscript"> for VBScript formatting
<pre lang = "xml"> for XML formatting

If you want to enter text like <pre lang = "xml">:

  1. Check the allow HTML radio button in the Tip/Trick editor "When Pasting" option list. Use the article editor to enter text. Copy its HTML and paste here.
  2. Learn the special text for symbols like <(&-lt-; Remove the - for the symbol)

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here