HTML – Code Element to Highlight Codes

Code Element to Highlight Codes

HTML <CODE> Element

If your pages include any programming code, scripting language code. Any codes on the webpage will be placed inside the <code> element.

The code element has ending tag </code>.

The <code> element is presented in a monospaced font, like the code in most of the programming language books.

HTML Code [With C Example]

<code>
#include<stdio.h> #include<conio.h> float carea(float); void main() { float radius; printf("Enter Radius:"); scanf("%f",&radius); carea(radius); getch(); } float carea(float radius) { float area; area=3.14159*radius*radius; printf("Area= %f",area); }
</code>

HTML Output

#include #include float carea(float); void main() { float radius; printf("Enter Radius:"); scanf("%f",&radius); carea(radius); getch(); } float carea(float radius) { float area; area=3.14159*radius*radius; printf("Area= %f",area); }

The <code> element is often used in conjunction with the <pre> element so that the formatting of the code is retained.