The <code> tag is used to format code in an HTML document. For example, if you want to write Java code and format it properly, then use the <code> element in HTML.
Let us now see an example to implement the <code> element in HTML −
Example
<!DOCTYPE html> <html> <body> <h1>Header Files</h1> <h2>C++</h2> <code> #include <iostream> </code> <h2>C</h2> <code> #include <stdio> </code> </body> </html>
Output
In the above example, we have set a small code snippet; header files in C and C++ on our web page −
<h2>C++</h2> <code> #include <iostream> </code>
The header file is set inside the <code> element that formats the code accordingly −
<code> #include <iostream> </code>