HTML <code> Tag
The <code> tag in HTML is used to define the piece of computer code. During the creation of web pages sometimes there is a need to display computer programming code. It could be done by any basic heading tag of HTML but HTML provides a separated tag which is <code>.
The code tag is a specific type of text which represents computer output. HTML provides many methods for text-formatting but <code> tag is displayed with fixed letter size, font, and spacing.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML course.
Some points about <code> tag:
- It is mainly used to display the code snippet into the web browser.
- This tag styles its element to match the computer’s default text format.
- The web browsers by default use a monospace font family for displaying <code< tags element content.
<code> Contents... </code>
The below examples illustrates the HTML code Tag.
Output: The program which is written inside the <code> tag has some different font size and font type to the basic heading tag and paragraph tag.
Note: <pre> tag is used to display code snippets because it always keeps the text formatting as it.
- Google Chrome
- Internet Explorer