- 1). Click the "HTML" tab on the top of the editing box on the "Edit Post" screen. Locate the position within the post content where you want to place source code and start a new line there.
- 2). Type out the code as you want it to appear within the post:
<h1>Sample Code</h1>
Replace the brackets surrounding each HTML tag with their corresponding special character codes:
<h1>Sample Code</h1>
Note that the special character code for the beginning bracket is "<" which stands for "less than." The ending bracket is ">" or "greater than." - 3). Wrap your source code sample in "<pre>" tags to preserve the code's white space, such as indentations and line breaks:
<pre>var x;
x = 5;</pre>
Do not start the code sample on a new line directly after "<pre>," because this causes an extra blank line to appear in the post. Since "<pre>" is not part of the source code, do not convert the brackets of the "<pre>" tags to special character codes. - 4). Wrap the source code and "<pre>" tags with "<code>" tags to format your code in a monospaced font:
<code><pre>var x;
x = 5;</pre></code>
previous post