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

the <samp> html tag
the <samp> html tag

The <samp> html tag

Overview

The <samp> 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 parts of programming code. Its use is almost identical to the <code> HTML tag. 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 <samp> tag it is displayed as a sample text.

Basic Usage

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

Advance Usage

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

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

Final Thoughts

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

Website for £99

Offers

 

Categories

 

Our blog

Some random stories from our blog.

Marketing in a Facebook world

With recent reports of Facebook being more popular then Google, we can begin to see the seeds of what has been predicted for some time now. With political parties now actively advertising on Facebook, is your online advertising budget still best served with Google, or has Google finally lost its Ad words Lustre. A free internet Google has always promoted a free internet for all users, and to support this came up with a way for advertisers to pay for user’s usage of its service. It is well documented that users are happy to give up some of their online soul, if it means the results are great applications, interfaces and information for free. With Google’s dominant position in the market place, it meant if there was a dollar to spend on advertising, nearly all went with Google. After all in marketing a bigger audience means better results. Advertise and…

The cost of free website builders

The <var> html tag

Taking over the Internet one site at a time

The <big> html tag

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