Tovi Jaeschke

Links:

Recent posts:

How to add syntax highlighting to your website

When running a programming blog, you are going to need to show some code. To make this look appealing, and easy for people to read, you should add syntax highlighting to your code.

First, select what code you want to support

And download the prism syntax code highlighting here prismjs.com. Then link it to your website like this:


<html>
    <head>
        <link rel="stylesheet" type="text/css" href="css/prism.css"/>
        <script src="js/prism.js"></script>
    </head>
    <body>
    <p>After you have linked the files, you can use prism with this code syntax:</p>
    <pre>
        <code class="language-<language>">
			Code Goes here!
        </code>
    </pre>
    </body>
</html>

You can also add other plugins, such as line numbers, show tabs and spaces, automatically link url's and emails, and WebPlatform Docs