Docs
← Back to site

Code Blocks: Syntax Highlighting & Copy Button

2 min readUpdated November 21, 2026

Code blocks get syntax highlighting, a language label, and a copy button automatically, no shortcode needed. This only works when the code is marked up correctly.

Adding a code block#

Use a Custom HTML block and write the code directly as HTML, including the language class:

<pre><code class="language-js">
function greet(name) {
  return `Hello, ${name}!`;
}
</code></pre>

function greet(name) {
  return `Hello, ${name}!`;
}

The language- prefix on the class attribute is what enables syntax highlighting and the language label. Use whatever language Prism.js supports, for example language-js, language-php, language-python, language-bash, or language-css.

What happens automatically#

Once a doc’s content contains a <pre><code> block, WP Super Docs:

  • Adds a small language label (matching whatever you put after language-) to the corner of the block
  • Adds a Copy button, which copies just the code text, not the label or button, and briefly shows “Copied!” after use
  • Applies Prism.js syntax highlighting based on the detected language

None of this loads on docs that don’t contain any code, so plain text-only docs aren’t affected.

Prism, which does the syntax highlighting, ships with the plugin and loads from your own site, with no requests to outside servers.

Code blocks without a language#

You can still use a plain <pre><code> block with no language- class. It still gets the copy button, just without a language label or syntax highlighting.

<pre><code>
Just some plain text or output, no highlighting needed.
</code></pre>

Just some plain text or output, no highlighting needed.

Multiple languages for the same example#

If you want to show the same snippet in more than one language (like curl, JavaScript, and Python versions of the same API call) as a tabbed interface instead of separate blocks, use the shortcode. See Multi-Language Code Tabs for details.

Was this helpful?

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only