HTML code tag

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

<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

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

a program

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

syntax highlighting

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

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.



Was this article helpful?