Code Tag Use to Represent Code Syntax in HTML5



The Code tag is used for indicating 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:

<!DOCTYPE html>
<
html>
<
head>
    <title></title>
</
head>
<
body>
    <p>
        In this line I am using  &lt;code&gt; tag. You should use <code>Server.MapPath()</code>
        to get virtual directory.</p>
    <p>
        In below line, I am not using &lt;code&gt; tag. To show the effect of code tag.<br />
        You should use Server.MapPath() to get virtual directory.</p>
    <code>
        <p>
            <code><strong>Programming language</strong></code></p>
    </code>
    <p>
        Code tag is used for indicating a source code of programming language. This code
        represent any variable name, type of variable, syntax of code, a filename, a computer
        program, or any type of code that computer would recognize. This tag is best used
        for short piece of code because it does not preserve white space.
    </p>
    <blockquote>
        <code><strong>Syntax:</strong></code>
        <br />
        <code>con.Open();<br />
            cmd.ExecuteNonQuery();<br />
            Response.Redirect("~/home.aspx"); </code>
    </blockquote>
</
body>
</
html>

Output

Internet Explorer

code tag in HTML5

Chrome

code tag in HTML5

Fire Fox

code tag in HTML5

Safari

code tag in HTML5

Up Next
    Ebook Download
    View all
    Learn
    View all