How to Display Code in HTML
To display the code on our website, we need to use HTML <code> tag. This tag is paired tag, so we need to create an opening and closing code tag. Inside it, we put any language code like C, C++, Java, etc. All the codes inside the <code> will display semantic code. The code tag is an inline-level element
Ex:
<p>printing in JS</p>
<code>
document.write("hello world");
</code>
In the above code, we have created <code> tag and inside it we put some JS code.
See the above code, the code is displayed successfully. This tag is very useful for user attraction of code.
Output: