ExpressionEngine® User Guide

Syntax Highlighting

[code] and Markdown code blocks output clean and properly marked up code samples ready for you to style. [1]

        ... your code sample...

The result is agnostic, flexible, and ready for you to style how you like. This guide shows you how easy it is to use popular highlighting libraries for pretty code.


You can pretty quickly get highlight.js working by dropping in these three lines of code:

<link rel="stylesheet" href="//">
<script src="//"></script>

That will automatically highlight and style all codeblocks. You can further customize the look by choosing a theme or selecting specific languages or by tweaking how it’s run.

If you want to specify a language, add a class to the <code> element:

<pre><code class="html">...</code></pre>

You can also do that using Markdown:

``` .html

Or using bbcode:


If you want to prevent syntax highlighting, add a class of nohighlight to the <code> element:

<pre><code class="nohighlight">...</code></pre>
``` .nohightlight

Other Options

Besides highlight.js we also recommend Prism and Rainbow. While highlight.js allows you to optionally specify the language, both Prism and Rainbow require that you specify the language. Beyond that, they work very similarly to highlight.js.

[1]As of version 3.3.0, ExpressionEngine no longer outputs ugly span tag syntax highlighting for code blocks.