Basic Tags

 

In the previous section you saw the most basic HTML script and tags needed for a Web page. The following table shows various extra tags you can use and explains what they do as HTML commands. You will notice that some of the tags might seem redundant, in that they more or less generate the same output. In these instances feel free to use the one you feel more comfortable with. To keep things a little clearer, I am only going to write what is in the <BODY></BODY> tags. I will omit the <HTML></HTML>, <HEAD></HEAD> and <TITLE></TITLE> tags. Needless to say, keep these in your document.

Tags and Meaning

Description

Paragraph Text

<P></P>

In order to give the appearance of paragraphs, you have to use the paragraph container tag. Web browsers ignore more than one space between words and will ignore returns that you add to your HTML file.

Lets take the following example:

<BODY>
This document provides complementary or late-breaking information to supplement the Microsoft Windows documentation.

Due to problems with power management on this computer, Windows does not have an option to switch to Standby using the Start/Shutdown menu.
</BODY>

It looks right when you type it into your editor. However, when it displays in a Web browser, it looks as follows:

This document provides complementary or late-breaking information to supplement the Microsoft Windows documentation. Due to problems with power management on this computer, Windows does not have an option to switch to Standby using the Start/Shutdown menu.

Properly formatted, it should look like this:

<BODY>
<P>
This document provides complementary or late-breaking information to supplement the Microsoft Windows documentation.
</P>
<P>
Due to problems with power management on this computer, Windows does not have an option to switch to Standby using the Start/Shutdown menu.
</P>
</BODY>

So the output will then look as follows:

This document provides complementary or late-breaking information to supplement the Microsoft Windows documentation.

Due to problems with power management on this computer, Windows does not have an option to switch to Standby using the Start/Shutdown menu.

A <TAG> tells the browser to do something. An ATTRIBUTE goes inside the <TAG> and tells the browser how to do it. As you probably know, the default value is a value that the browser assumes if you have not told it otherwise.

The <P></P> tags has an attribute ALIGN, and can have the values LEFT, CENTER or RIGHT. Take the following example:

<P ALIGN="CENTER">
This text is centered.
</P>

And this is what the output will look like in your browser:

This text is centered.

Line Breaks

<BR>

If you want to decide where a line is going to end, you'll use this tag. Let's say you have the following:
<BODY>
Richard Smith
14234 Main Street
Anycity, St 00001
</BODY>

It looks about right when you type it into your editor. However, when it displays in a Web browser, it looks as follows:

Richard Smith 14234 Main Street Anycity, St 00001

The answer is the empty tag <BR>, which forces a line return in your Web document. Properly formatted, it should look like this:

<BODY>
Richard Smith<BR>
14234 Main Street<BR>
Anycity, St 00001<BR>
</BODY>

So the output will then look as follows:

Richard Smith
14234 Main Street
Anycity, St 00001
Header Text

<Hn></Hn> where "n" can be 1, 2, 3, 4, 5 or 6.

<H1></H1>, is the largest for headlines or page titles and <H6></H6>, is the smallest header. The following example shows the six different headers:

H1

H2

H3

H4

H5
H6

Properly formatted, it should look like this:

<BODY>
<H1>Welcome</H1>
</BODY>

The output will then look as follows:

Welcome

The <Hn></Hn> tags has an attribute ALIGN, and can have the values LEFT, CENTER or RIGHT. Take the following example:

<H3 ALIGN="CENTER">
This heading is centered.
</H3>

And this is what the output will look like in your browser:

This heading is centered.

Preformatted Text

<PRE></PRE>

The <PRE> tag is designed to allow you to keep the exact spacing and returns that you've put between the on and off tags. Consider the following examples:
<BODY>
Oh beautiful, for spacious skies.
For amber waves of grain.
For purple mountains' majesty.
Above the fruited plains.
</BODY>

In the browser the above mentioned paragraph will be one straight line, without any spaces or line breaks, like this:

Oh beautiful, for spacious skies. For amber waves of grain. For purple mountains' majesty. Above the fruited plains.

Now look at the next example using the <PRE></PRE> tags:

<BODY>
<PRE>
Oh beautiful, for spacious skies.
For amber waves of grain.
For purple mountains' majesty.
Above the fruited plains.
</PRE>
</BODY>

In the browser the paragraph will appear exactly as it is typed between the on and off tags.

Oh beautiful, for spacious skies.
For amber waves of grain.
For purple mountains' majesty.
Above the fruited plains.
Horizontal rule

<HR>

Draws a line across the width of your document or table, and has the following attributes: WIDTH, SIZE, ALIGN and NOSHADE. Properly formatted the <HR> tag should look like this:
<BODY>
<HR>
</BODY>

And this creates the following output:


The following is an example of a horizontal line with its attributes:

<BODY>
<HR SIZE="number" WIDTH="number or percentage" ALIGN="direction" NOSHADE>
</BODY>

and this is what it will look like with actual values, note however, width can be entered as a percentage (WIDTH="50%") or pixel (WIDTH="100") value:

<BODY>
<HR SIZE="5" WIDTH="75%" ALIGN="CENTER">
</BODY>

The ALIGN attributes' values can be either LEFT, RIGHT or CENTER. This attribute is designed to align the bar horizontally on the page.

NOSHADE is only used if you don’t want the horizontal line displayed with a shadow, in short this attribute makes it a solid line.

This is what the output of the above piece of script will look like:


Lets do another one:

<BODY>
<HR SIZE="8" WIDTH="75%" ALIGN="CENTER" NOSHADE>
</BODY>

This is what the output of the above piece of script will look like:


Bold Text

<B></B>

Bold text is text that will display darker than the rest of the text on a page. Properly formatted, it should look like this:
<BODY>
<B>This is Bold Text</B>
</BODY>

The output will then look as follows:

This is Bold Text

Italic Text

<I></I>

The italic tags will make the text lean to the right on a page. Properly formatted, it should look like this:
<BODY>
<I>This is Italic Text</I>
</BODY>

The output will then look as follows:

This is Italic Text

Underlined Text

<U></U>

The underline tags draws a line beneath the specified text. Properly formatted, it should look like this:
<BODY>
<U>This is Underlined Text</U>
</BODY>

The output will then look as follows:

This is Underlined Text

Emphasis

<EM></EM>

Like Italic Text
Strong Emphasis

<STRONG></STRONG>

Like Bold Text
Teletype

<TT></TT>

Monospaced text, makes the text look like type writer text. Properly formatted, it should look like this:
<BODY>
<TT>Makes the font look like type writer text.</TT>
</BODY>

The output will then look as follows:

Makes the font look like type writer text.

Now guess which tags I used to display the HTML code in my tutorial.

Blinking text

<BLINK></BLINK>

This makes the text appear and disappear in regular intervals on the page. Properly formatted, it should look like this:
<BODY>
<BLINK>Now you see me... now you don't.</BLINK>
</BODY>

The output will then look as follows, note however that the blink tags do not seem to function correctly with Internet Explorer, but does work fine with Netscape Navigator, so if you are not using Netscape, the following example might not be blinking:

Now you see me... now you don't.

Citation Text

<CITE></CITE>

Sample Text

<SAMP></SAMP>

Definition Text

<DFN></DFN>

Code Text

<CODE></CODE>

Variable Text

<VAR></VAR>

Keyboard Text

<KBD></KBD>

Strikethrough Text

<STRIKE></STRIKE>

The list of tags on the left are all just different ways of formatting your text on a page. They all get used like the previous tags and if properly formatted will generate an output similar to the following:

This is what Citation text will look like.

This is what Sample text will look like.

This is what Definition text will look like.

This is what Code text will look like.

This is what Variable text will look like.

This is what Keyboard text will look like.

This is what Strikethrough text will look like.

 

You can also combine tags. Making a piece of text bold and italic would require the following piece of script:

<B><I>BOLD ITALIC</I></B>

If you are going to use tag pairs in combination, then to avoid confusing the browser, they should be nested, not overlapping. Let me illustrate:

<STRONG><STRIKE></STRONG></STRIKE> Overlapping tags, this is not good.
<STRONG><STRIKE></STRIKE></STRONG> Nested tags, this is good.

Well, let's see what all these tags will look like in a complete HTML page. The following example is an HTML file that will use all the tags we have gone through up to now.

<HTML>
<HEAD>
<TITLE>Tag Examples</TITLE>
</HEAD>
<BODY>
<H1>Tag Examples</H1>
<P>
On this page we're reviewing the different types of tags that we've learned in this chapter. For instance this is the first paragraph.
</P>
<P>
In the second paragraph, I'm going to include the name and address of one of my favorite people.<BR><BR>
Tom Smith<BR>
1010 Flower Lane<BR>
Anywhere, SA 2000
</P>
To spice up your text you can make it <B>BOLD</B>, <I>ITALIC</I> or <U>UNDERLINED</U>.<BR>
Or even combine the tags to make <B><I>BOLD ITALIC</I></B> or <I><U>ITALIC UNDERLINED</U></I>.
<P>
Other interesting font effects are <EM>Emphasis</EM>, <STRONG>Strong</STRONG>, <TT>Teletype</TT>, <BLINK>Blink</BLINK>, <CITE>Citation</CITE>, <SAMP>Sample</SAMP>, <DFN>Definition</DFN>, <CODE>Code</CODE>, <VAR>Variable</VAR>, <KBD>Keyboard</KBD> and <STRIKE>Strikethrough</STRIKE> text.
</P>
<P>
So this is all fine and well, but how does one make columns? Well, you use the preformatted text tag.
</P>
<HR SIZE="3" WIDTH="90%" ALIGN="CENTER">
<TT>
<PRE>
Quantity XJS100 RJS200 YJS50 MST3000
1-50 $40 $50 $75 $100
50-99 $35 $45 $70 $95
100-200 $30 $40 $65 $90
200+ $25 $35 $55 $75
</PRE>
</TT>
</BODY>
</HTML>
screen.gif (1270 bytes) Click here to see what the output of the above code would look like. To come back to this page when you've finished looking at the result, close the new window it opened in.
output.gif (894 bytes) Click here to go to the personal homepage example, for this section of the tutorial. 

 

[Next Section - More HTML Tags] [Back To Index Page]

Introduction | Basic Tags | More HTML Tags | List Tags | Adding Graphics | Creating Links | Adding Forms | Adding Tables
Creating Frames | Multimedia | Uploading Files | Downloads | Questions & Answers | Useful Links | e-mail Me
 
Example Page 1 | Example Page 2 | Example Page 3 | Example Page 4 | Example Page 5 | Example Page 6
Example Page 7 | Example Page 8 | Example Page 9 | Example Page 10
 
Color Chart | HTML Tester
bar.gif (1848 bytes)
Copyright © 1999 - 2000 Green Tentacle. All rights reserved. This tutorial is protected by SA and international copyright laws.
Hosted by www.Geocities.ws

1