The code tag
The code
tag is used to enclose the program code of any languages that you want to place in the text of your HTML page.
Please note that tags inside code
will work as tags. To prevent the browser from interpreting them as a command, you should replace all angle brackets with the special HTML characters <
and >
or use the non-standard tag xmp
.
Text placed inside the code
tag will become by default monospaced (this means that the length of all letters will be the same). This behavior can be changed using the CSS property font-family
.
Example
Let's look at how to use the code
tag:
We introduce a variable <code>$a = 3;</code>
: