By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

HTML Code Tag

Reference on the Code Tag of HTML, its useful example, and a list of allowed attributes.

Edited: 2014-12-28 07:09

The HTML code element is used to markup source code, such as HTML, css, JavaScript. Etc. Rendering code as text is done by replacing ">" with "&gt;" and "<" with "&lt;".

Most sites are using pre instead.

Attributes

Standard Attributes

Attribute:Value:Description:DTD:
AttrsOther AttributesCommon, Event, I18nSTF

DTD. Defines which document type the attribute is allowed. S=Strict, T=Transitional, F=Frameset.

Example

The below shows how to markup code in HTML pages, using code tags.

 <code>
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;

  &lt;head&gt;
    &lt;title&gt;My first Website&lt;/title&gt;
  &lt;/head&gt;

  &lt;body&gt;
    &lt;p&gt;My first Website.&lt;/p&gt;
  &lt;/body&gt;

&lt;/html&gt;
 </code>