Category: 

What is an HTML Code Tag?

Article Details
  • Written By: Victoria Blackburn
  • Edited By: Bronwyn Harris
  • Last Modified Date: 07 November 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
Contrary to popular belief, monkeys do not eat bananas in the wild because the banana is a cultivated fruit.  more...

December 6 ,  1877 :  Edison demonstrated the first sound recording.  more...

All HTML documents are made up of text only. These documents include both the text to be displayed and instructions on how it should be displayed by the Internet browser. The instructions are given by the tags that are included in the text document. The HTML code tag is one such instruction, and it identifies text as computer code.

When using most tags, it is necessary to include an opening and closing tag so the browser knows where to use the instructions. The code tag is one of the tags that must have an opening and closing tag. When the it is used, it takes the following format: <code>hello</code>. If this instruction were read by the browser, it would change how the word hello is formatted so that it is differentiated from other text on the page. Usually, when the code tag is used, a browser changes the font of the words surrounded by the tags to monospace, or a font similar to that.

Ad

This tag doesn’t have any specific attributes, or characteristics, that are unique. When writing an HTML document, the format of any computer code takes can be specified by using other general attributes. If style sheets are being used for formatting the document, id, class and style can be used to point to how the text is styled. Other attributes that can be included with the code tag are title, lang and dir title gives a specific title to the tag, lang specifies the language, and dir gives the direction of the text, from left to right or right to left.

Events are actions taken by a web user, such as clicking or double clicking something on the page. These events can be coded for within the HTML document and can also be included within the code tag. Optional events that can be used as attributes for the code tag include onclick, ondblclick, onkeydown, onkeypress, onkeyup, onmousedown, onmouseup, onmouseover and onmouseout.

Most browsers have a default style to use when the code tag is encountered within an HTML document. Using attributes with this tag is completely optional, so none have to be specified. If the attributes are not included, the browser will just use the default setting. It is important to note that not all browsers will display code text in the same way. The browsers will display the code text differently than the surrounding text of the page, but each browser may not format the code text in the same way if attributes and styles are not included within the code tag.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email