Enhance your code presentation with JavaScript libraries like Highlight.js or Prism.js. You can use these libraries to highlight the <pre>
and <code>
sections. Alternatively, consider embedding your code snippets using GitHub gist.
If you choose Highlight.js, you can download the required javascript files or use the following snippet:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></ script>
<script>hljs.initHighlightingOnLoad();</ script>
Example usage:
<pre><code class="css"> --your code goes here-- </code></ pre>
. Remember to change the class name to
class="js"
for JavaScript code.
If Prism.js is your preferred library, include the necessary styles and scripts as follows:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.8.4/themes/prism.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.8.4/prism.min.js"& gt;</script>
Usage example:
<pre><code class="language-css"> --your code goes here-- & lt;/code></ pre>
. Change the class to
class="language-js"
for JavaScript code.
You can explore various themes available for each library to suit your project.
To embed your code using GitHub gist, simply paste your code, create a public gist, copy the provided embed link, and paste it into your HTML.