Home > Software design >  How to display CPP, Java or any other programming language codes in proper format in html page?
How to display CPP, Java or any other programming language codes in proper format in html page?

Time:10-08

I want to write codes in proper format in a blog as Sample here

How it can be done? Is there any plugin that I need to install?

CodePudding user response:

You can use the "Plugin" from Google called code pretiffier. First of all import the following script into your website:

<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>

After you imported this, you can write the wished code into a pre tag with the class "prettyprint". It should look like this:

<pre class="prettyprint">
   //Your custom code
</pre>
  • Related