Skip to content

Code

This section provides guidelines for writing code snippets in Kinsta content. These guidelines cover topics such as formatting and syntax highlighting.

Code blocks

Code should be enclosed with code tags and highlighted accordingly. This ensures it’s imported to WordPress properly.

For example:

<pre><code class="language-html"><link rel="stylesheet" href="./style.css"></code><pre>

Renders (highlighted for language-html): <link rel="stylesheet" href="./style.css">

Ensure the code class portion (language-html) reflects the actual language of your code. On Kinsta’s website, we use Prism for syntax highlighting. See the supported highlighting classes on Prism’s documentation.

If you’re unsure which to use, default to language-markdown.

Inline code blocks

When referencing functions, elements, or snippets of code in your content sentences, surround the code with inline <code> blocks:

  • Learn how to use the phpinfo() function.
    • Renders: Learn how to use the phpinfo() function.
  • Images should always include descriptive text in the alt attribute.
    • Renders: Images should always include descriptive text in the alt attribute.

Note: When the term is not a word (noun, verb, preposition, etc), not a feature, product, or brand name, it’s most likely code. Always wrap code into inline code blocks.