HighlightJS Simple Example

by John Doe

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/highlight.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/styles/vs.min.css">
<pre><code class="html"><form action="myForm.php" id="my_form" method="post">
    <input type="text" name="user_name"  id="user_name" />
    <input type="email" name="email" id="email" />
    <input type="password" id="password" name="password" />
    <input type="submit" name="submit" id="submit" />
</form></code></pre>

JavaScript

$(document).ready(function () {

	$("pre code").each(function () {
		$(this).html($("<p/>").text($(this).html()).html());
    
    	hljs.highlightBlock(this);
	});

});