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

the <pre> html tag
the <pre> html tag

The <pre> html tag

Overview

HTML tags are good at the job they do, but often there are limitations. In normal copy there is often a double space after a full stop, if you try this in HTML you will see the extra space is ignored when displayed to screen. the <pre> HTML tag is displays text using a fixed spaced font, which also has the advantage of retaining spaces and line breaks. In short using the <pre> tag will allow you to keep double spaces in your copy. When text is put between the opening and closing <pre> tag it is displayed as a Preformatted text. By default the font will be Courier, but this can be changed.

Basic Usage

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

Advance Usage

It is possible to style and add functionality to the <pre> tag, this is done by adding an attribute to after the pre in the opening <pre> tag
Attributes allowed for the <pre>tag include :-class, dir, id, lang, style and title.
In most cases class and id are used and its basic usage is shown below
<pre id=”header”>Some Preformatted text</pre>
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 <pre> tag the class attribute is nearly always used over the id attribute.
The attribute style allows you to include css style information for a single <pre> 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

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

Final Thoughts

Touching on just the surface of the <pre> 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.

The <dfn> html tag

Overview The <dfn> HTML tag is known as a phrase tag, it is mainly used to style text. By default it makes text italic to illustrate that the tag text is a definition. 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 <dfn> tag it is displayed as a definition text. Basic Usage <dfn>Some definition text in here</dfn> Any text between the opening and closing tag will be displayed as a definition text. Advance Usage It is possible to style and add functionality to the <dfn> tag, this is done by adding an attribute to after the p in the opening <dfn> tag Attributes allowed for the <dfn>tag include :-class, dir,…

Apple to buy Google

In a shock announcement Apple has bought a controlling share in the Internet giant Google. Apple has cited its reason behind the purchase ‘To expand from the digital desktop to a centric focused digital lifestyle’. Also in its announcement, were plans ‘within a reasonable timescale’ to phase out Google Checkout with all services being transferred to its ‘ITunes Store’. There is some speculation that the Store will now face some re positioning due to Apples new focus. Where does this leave web users and competing companies like Microsoft. Safari, Apples flagship web browser is due for a major upgrade in the Q3 this year, with the introduction of its I-Game and I-See Safari Web based plug-ins. Both these Safari only plug-ins will integrate game and music content direct into the safari browser for a totally seamless entertainment experience. People not using Safari will not have access to this killer functionality,…

The <h6> html tag

In HTML h tags stand for heading and this is split into 6 different h tags (h1, h2, h3, h4, h5 and h6). By default it is displayed as bold and much smaller version of the body text. As with all h tags it is considered important for SEO.When text is put between the opening and closing <h6> tag it is displayed as a Small heading. Unlike <h1> a <h6> tag can be used multiple times on a webpage as its job is to be the heading for a web pages sub topics. The <h6> tag is not used often due to 5 other h tags being available. Basic Usage <h6>Smallest header text</h6> Any text between the opening and closing tag will be displayed as a very small heading. Advance Usage It is possible to style and add functionality to the <h6> tag, this is done by adding an attribute…

The <p> html tag

Overview In simple terms the <p> HTML tag stands for paragraph. When text is put between the opening and closing <p> tag it is displayed as a paragraph. It is for this reason when you view most of the body copy in the source of a webpage you will see it sitting between <p></p> Basic Usage  <p>Some text in here</p> Any text between the opening and closing tag will be displayed as a paragraph. Advance Usage It is possible to style and add functionality to the <p> tag, this is done by adding an attribute to after the p in the opening <p> tag Attributes allowed for the <p>tag include :-class, dir, id, lang, style and title. In most cases class and id are used and its basic usage is shown below <p id=”header”>Some text</p> With all attributes there is a space after the initial p then the attribute name,…

Number of backlinks

Overview When optimising an HTML webpage, factors other than on page and visible changes are also important. Techniques which look to affect search engine optimisation that are not applied to the site itself is known as off page search engine optimisation. History of backlinks Off page search engine optimisation with regards to the Google search engine, as well as others, came from the knowledge that copy on the page can be crafted to appear more relevant to search terms and therefore can artificially affect a pages position on search rank. As Google defined itself as an information engine, its vision was to give people the most relevant website pages for their chosen search term. And with unscrupulous website owners looking to gain unfair advantage, Google made the decision to include factors (or signals) that couldn’t easily be manipulated. One of the way Google came up with, was to assume if…

© 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