the <code> html tagWebsites by Mark - 7 Woodrush gardens, Carterton, Oxfordshire. OX18 1JE

the <code> html tag
the <code> html tag

The <code> html tag

Overview

The <code> HTML tag is known as a phrase tag, it is mainly used to style text. By default it displays text in a fixed width font which is ideal for displaying samples of programming code. It works equally as well in table based layouts as well as CSS based ones. As with all phrase based HTML tags it can be used in situations where consistancy between browsers is difficalt to acheive in other ways. When text is put between the opening and closing <code> tag it is displayed as a code text.

Basic Usage

<code>Some code text in here</code>
Any text between the opening and closing tag will be displayed as a code text.

Advance Usage

It is possible to style and add functionality to the <code> tag, this is done by adding an attribute to after the p in the opening <code> tag
Attributes allowed for the <code>tag include :-class, dir, id, lang, style and title.
In most cases class and id are used and its basic usage is shown below
<code id=”header”>Some code text</code>
With all attributes there is a space after the initial p then the attribute name, then an equal’s sign and the identifier of the attribute in double quotes.
Both id and class attributes refer to CSS styling of the element and is either stored in the <head> of the webpage on in an external file.
With id this usually refers to a single instance on a page where as class usually refers to a repeating element on a page, it is for this reason for the <code> tag may use either the id or class as an atribute.
The attribute style allows you to include css style information for a single <code> tag.
The dir attribute allows for left reading and right reading text, lang allows you to specify a language for the tag and title allows you to include extra information for a tag.
It is possible to attach scripts to tags, as well adding functionality to a webpage, these scripts tend to be written in Javascript and therefore outside the scope of this document

Examples

<code>Some code text</code> – basic usage example.
<code id=”header>Some code text</code> – code text which is styled by the id header.
<code class=”headerclass”> Some code text </code> – code text which is styled by the class headerclass.
<code id =”header” class=”headerclass”> Some code text </code> – code text which is styled by the class headerclass and the id header.
<code style="color:#F00">Some code text</code> – code text which has a custom colour of red.
<code dir="rtl">Some code text</code> – code text where the text reads from right to left.
<code lang="uk">Some code text</code> – code text where the language has been tagged as UK.
<code title="ptitle">Some code text</code> – code text where the tag has been titled ptitle.

Final Thoughts

Touching on just the surface of the <code> HTML tag it is easy to see how versatile it is. To take full advantage of it an understanding of CSS is an advantage.

Our blog

Some random stories from our blog.

Case Study – Biznet

When six individuals came together to create Biznet, a local business networking group, it wasn’t long before the idea of a website was born. For such an exciting on-going project Websites by Mark were more than pleased to be invited to design, create and maintain the new system. By mixing strong visuals and practical flexibility has meant a site has been created that not only drives traffic from search engines, but also retain and converts visitors to members. As with any new group requirements, flexibility is often the key and the sites modular design allows for rapid and agile changes to be made within a very short timeframe. Like all Websites by Mark sites, listing on the major search engines happened in just a few days, and with its built-in features means SEO and SERP will naturally build and expand overtime. By using cutting edge prototyping and creation tools, the…

The <cite> html tag

Overview The <cite> HTML tag is known as a phrase tag, it is mainly used to style text. By default it displays text as italic which is ideal for showing a quotation or citation. It works equally as well in table based layouts as well as CSS based ones. As with all phrase based HTML tags it can be used in situations where consistancy between browsers is difficalt to acheive in other ways. When text is put between the opening and closing <cite> tag it is displayed as a citation text. Basic Usage <cite>Some citation text in here</cite> Any text between the opening and closing tag will be displayed as citation text. Advance Usage It is possible to style and add functionality to the <cite> tag, this is done by adding an attribute to after the cite in the opening <cite> tag Attributes allowed for the <cite>tag include :-class, dir,…

The <strike> html tag

Overview The <strike> HTML tag is mainly used to style text. By default it displays text as with a strikethrough line through it which is ideal for showing corrections or previous amended text. It works equally as well in table based layouts as well as CSS based ones. As with all phrase based HTML tags it can be used in situations where consistancy between browsers is difficalt to acheive in other ways. When text is put between the opening and closing <strike> tag it is displayed as a strikethrough text. Basic Usage <strike>Some strikethrough text in here</strike> Any text between the opening and closing tag will be displayed as strikethrough text. Advance Usage It is possible to style and add functionality to the <strike> tag, this is done by adding an attribute to after the strike in the opening <strike> tag Attributes allowed for the <strike>tag include :-class, dir, id,…

Will Yell kill off your local SEO Company?

UK based Yell.com the internet arm of the yellow pages directory has been slowly moving to increase what services it offers to the online world. Recently it unleashed SEO Web Pages to a limited amount of clients. This service offers the promise of professional SEO for all those who pay for advertising with Yell. Is this a breakthrough service or do SEO companies have nothing to fear? Video killed the radio star Back in 1883 a USA company made the decision to print its business directory on yellow paper due to paper supply and the Yellow Pages as we know it today was born. Since then the popularity of the publication has gone from strength to strength and is available in many countries across the world. Indeed before Google, if you wanted to advertise a product or service the Yellow Pages was the platform of choice. Next generation platform Within…

Anchor texts of backlinks

Overview Anchor text is a technical term to describe any text which is a link… There is also a version of this that applies to images links. Due to recent Google updates this technique is not as important as it once was, but it should still be looked at History of Anchor text Tim Berners-Lee, a former telecoms engineer is widely regarded as the person who invented the internet as we see it today. Amongst the technologies he created, the ability to navigate between documents was to become known as a hyperlink, and without it, it could be argued that the net would simply not function. Beyond being simply a technology to link documents, by ‘naming’ the link, it allowed people to get an idea of what a web page contained before going to it. When the Google search engine was released, one of the signals Google looked at was…

© 2011 Websites by Mark. Do not reproduce any part of this website without permission.
Email : mark@websitesbymark.co.uk - Phone : 07716 447228 / 01993 820005
Postal Address : 7 Woodrush Gardens, Carterton, Oxfordshire. OX18 1JE