Create a syntax highlighting code with JavaScript.


To create a syntax-highlighting code with JavaScript, use the prettify library. Add the following in your code to add the library for syntax highlighting −

<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>

To use it, add the following to your <pre> tag −

<pre class="prettyprint">
   Code comes here
</pre>

Updated on: 23-Jun-2020

112 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements