Search code examples
htmlhighlight

Highlight code in HTML using <font color="#xxx">


I want to know how to highlight my code in HTML like this.

<font color="#1773cc">#include </font><font color="#4a6f8b">&lt;NTL/ZZ.h&gt;</font><br>
<br>
<font color="#b02f60"><b>using</b></font>&nbsp;<font color="#008b00"><b>namespace</b></font>&nbsp;std;<br>
<font color="#b02f60"><b>using</b></font>&nbsp;<font color="#008b00"><b>namespace</b></font>&nbsp;NTL;<br>
<br>
<font color="#008b00"><b>int</b></font>&nbsp;main()<br>
{<br>
&nbsp;&nbsp; ZZ a, b, c; <br>
<br>
&nbsp;&nbsp; cin &gt;&gt; a; <br>
&nbsp;&nbsp; cin &gt;&gt; b; <br>
&nbsp;&nbsp; c = (a+<font color="#ff8b00">1</font>)*(b+<font color="#ff8b00">1</font>);<br>
&nbsp;&nbsp; cout &lt;&lt; c &lt;&lt; <font color="#4a6f8b">&quot;</font><font color="#8a2ae2">\n</font><font color="#4a6f8b">&quot;</font>;<br>
}<br>

code from here

Just using <font color="#xxxxxx">xxx<font> to highlight code.
Is there a tool to implement this, or I have to write it by hand?

I've tried some tools, like Typora and Vim, but that's not what I want.

I want to highlight code using <font color="#xxxxxx">xxx<font>.

Is there a tool to implement this, or do I have to write it by hand?


Solution

  • To highlight your HTML code you have to use a library on your website. There you can find many libraries for this purpose but I think this is one of the best options you could have.

    https://highlightjs.org/

    Please visit the link and follow the instructions to include.

    PS: I don't recommend writing it on your own.