Code Tag Use to Represent Code Syntax in HTML5

Introduction

 
The Code tag is used for indicating the source code of a programming language. The code tag represents any variable name, type of variable, a filename, a computer program, or any type of code that a computer would recognize. This tag is best used for short pieces of code because it does not preserve white space.
 
Syntax
 
<cite  class=class names
id=specify unique id
style="style information > 
</cite>
 
Attributes Introduced by HTML5
accesskey
contenteditable
contextmenu
data-X
draggable
hidden
itemid
itemprop
itemref
itemscope
itemtype
spellcheck
tabindex
 
HTML5 Event Attributes
onabort onblur oncanplay
oncanplaythrough onchange onclick
oncontextmenu ondblclick ondrag
ondragend ondragenter ondragleave
ondragover ondragstart ondrop
ondurationchange onemptied onended
onerror onfocus onformchange
onforminput oninput oninvalid
onkeydown onkeyup onload
onkeypress onloadeddata onloadedmetadata
onloadstart onmousedown onmousemove
onmouseout onmouseover onmouseup
onmousewheel onpause onplay
onplaying onprogress onratechange
onreadystatechange onscroll onseeked
onseeking onselect onshow
onstalled onsubmit onsuspend
ontimeupdate onvolumechange onwaiting
 
Code:
  1. <!DOCTYPE html>  
  2. <html>  
  3.     <head>  
  4.         <title></title>  
  5.     </head>  
  6.     <body>  
  7.         <p>  
  8.         In this line, I am using the <code> tag. You should use   
  9.             <code>Server.MapPath()</code>  
  10.         to get virtual directory.  
  11.         </p>  
  12.         <p>  
  13.         In the below line, I am not using <code> tag. To show the effect of the code tag.  
  14.             <br />  
  15.         You should use Server.MapPath() to get virtual directory.  
  16.         </p>  
  17.         <code>  
  18.             <p>  
  19.                 <code>  
  20.                     <strong>Programming language</strong>  
  21.                 </code>  
  22.             </p>  
  23.         </code>  
  24.         <p>  
  25.         Code tag is used for indicating a source code of programming language. This code  
  26.         represent any variable name, type of variable, syntax of code, a filename, a computer  
  27.         program, or any type of code that the computer would recognize. This tag is best used  
  28.         for a short piece of code because it does not preserve white space.  
  29.     </p>  
  30.         <blockquote>  
  31.             <code>  
  32.                 <strong>Syntax:</strong>  
  33.             </code>  
  34.             <br />  
  35.             <code>con.Open();  
  36.                 <br />  
  37.             cmd.ExecuteNonQuery();  
  38.                 <br />  
  39.             Response.Redirect("~/home.aspx");   
  40.             </code>  
  41.         </blockquote>  
  42.     </body>  
  43. </html>  
Output
 
Internet Explorer
 
code tag in HTML5
 
Chrome
 
code tag in HTML5
 
FireFox
 
code tag in HTML5
 
Safari
 
code tag in HTML5