CSS Only Syntax Highlighter

Category: CSS & CSS3 | June 28, 2022
Views Total:2,552 views
Official Page:Go to website
Last Update:June 28, 2022


CSS Only Syntax Highlighter


The pure CSS syntax highlighter is a simple JavaScript-free tool that lets you highlight source code using only CSS classes.

How to use it:

1. Download and insert the syntax.css into the document.

<link rel="stylesheet" href="./syntax.css" />

2. Add the CSS class ‘syntaxbox’ to the ‘code’ tag.

<code class="syntaxbox">

3. Highlight your source code using the following CSS classes:

  • identifier: HTML element identifier.
  • identifier end: HTML element identifier (end).
  • value: Value
  • value link: Link
  • attribute: HTML attributes
  • newline: New line
  • comment: HTML comment
<code class="syntaxbox">
  <span class="newline">
    <span class="identifier">code
      <span class="attribute">class</span>
      <span class="value">syntaxbox</span></span>
    <span class="newline"></span>
    <span class="newline" data-level='1'>
      <span class="comment">HTML Comment</span>
    <span class="newline" data-level='1'>
      <span class="identifier">a
        <span class="attribute">href</span>
        <span class="value link">https://www.cssscript.com</span>
      <span class="identifier end">a</span>
    <span class="newline"></span>

You Might Be Interested In:

Leave a Reply