Web4College

HTML code tag

<code> tag defines a computer coded style of a piece of text. For instance, a computer program.

Example
Try it
<p><code>Here code starts. But it does not present pre-defined style of coding</code></p>

Here code starts. But it does not present pre-defined style of coding

Tag Uses

Specific uses of <code> tag

file name

Example
Try it
<p><code>table.html</code> page is about the tables.</p>

a program

Example
Try it
<pre><code>
var x,y;
 function sum(x,y){
	document.write(x+y);
 }
 sum(5,4);
</code></pre>

syntax highlighting

Example
Try it
<pre><code>
<span style="color:blue; font-family:italic;">var</span> x,y;
<span style="color:red; font-family:italic;">function</span>{
}
</pre></code>

Tag omission

Both opening and closing tags are necessary for the code tag.

Global Attributes

All the global attribute are applicable on the code element.