How to insert code into a WordPress posts

There are two basic steps to insert code in our post:

Insert the code with “code” tag and install a plugin to get a good visual effect.

1.- Insert the code with the tags.

How-to-insert-code-in-a-WordPress

 

 

 

 

 

2.- Get and activate a plugin. In this case I have choosen SyntaxHighlighter Evolved plugin.

Result:

#button {
    font-weight: bold;
    border: 2px solid #fff;
}

 

There are lots of parameter controls to get the best results. In the example below I add (language=”html” firstline=”33″) if a want the code starts in the line number 33

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>WordPress.com Code Example</title>
</head>
<body>
    <h1>WordPress.com Code Example</h1>

    <p><?php echo 'Hello World!'; ?></p>

    <p>This line is highlighted.</p>

    <p>This line is very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long.</p>

    <div class="foobar">
        This    is  an
        example of  smart
        tabs.
    </div>

    <p><a href="http://wordpress.com/">WordPress.com</a></p>
</body>
</html>

For more information Code ┬╗Posting Source Code.