Business & Finance Blogging

How to Format Source Code for Blog Posts on Wordpress

    • 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>

Related posts "Business & Finance : Blogging"

Writing Good Blogs

Blogging

Making Money From Blogs Does Not Have to Be a Difficult Process

Blogging

Get Started With Your Blog!

Blogging

Powerful Podcasting

Blogging

Monetize Your Blog and Earn From Your Hobby

Blogging

Blog Posts - Top Tips For Writing Attractive Blog Posts - Part 3

Blogging

Why Have a Blog About My Handcrafted Jewelry Business?

Blogging

How To Build Blog Income For Your Work At Home Business

Blogging

Best Top Blogs - WordPress vs Blogger

Blogging

Leave a Comment