In Lesson Four, you were introduced to two types of tags - that is, two types of formatting techniques. They were:
With physical tags or physical formatting, the browser is forced to print the text in exactly the way that the designer intends. If the browser does not support those choices, then the tags are ignored because the browser has no alternative way to display the text. Examples of physical tags are <I> and <B>.
In this lesson, I am presenting some additional text formatting
alternatives to complete what was begun in earlier lessons. Some of these
alternatives are logical elements and some are physical elements.
<BASEFONT SIZE="5">
Note the following discussion points:
For example, while <BASEFONT SIZE="5"> would set the default base font size to "5",
<BASEFONT SIZE="+5">
would set the new default base font size 5 levels larger than the current base font size. A "relative" size is always given "relative" to the current default size. Thus while <BASEFONT SIZE="2"> gives a default base font of size "2",
<BASEFONT SIZE="-2">
would give a base font size 2 levels smaller than the default size and
<BASEFONT SIZE="+2">
would give a base font size 2 levels larger than the default size.
U N B E L I E V A B L E !
The FONT tag can be used to change the size of one or more characters of text or of an entire block of text. Changing the font size of a few characters or of a few words is a good way to make your text stand out or to create some interesting effects. To change the font size of a few characters or of a block of text to size "4", the FONT tag is:<FONT SIZE="4">text text text</FONT>
Discussion:
This is a font size of 1
This is a font size of 2
This is a font size of 3
This is a font size of 4
This is a font size of 5
This is a font size of 6
This is a font size of 7
<FONT SIZE="+2">text text text</FONT>
will print the text 2 levels or 2 steps larger than the default font.
and
<FONT SIZE="-3">text text text</FONT>
will print the text 3 levels smaller than the default font.
The format for making the text a little bigger is:
<BIG>text text text</BIG>
and the format for making the text a little smaller is:
<SMALL>text text text</SMALL>
However, not all browsers display the effect of the BIG and SMALL elements in the same way. In fact, when combined with the BASEFONT or FONT tags, the results can be unexpected. For example, in Firefox and Netscape, text formatted with BIG is always one size larger than the surrounding text. In Explorer, text formatted with BIG is also always one size larger than the surrounding text, unless the surrounding text is size 7 in which case BIG has no effect. Text formatted with SMALL is one size smaller than the surrounding text, unless the surrounding text is size 1, in which case SMALL has no effect. Now, as long as the text is normal size (3), Firefox, Netscape and Explorer all display BIG and SMALL in the same way.
So, if you want to ensure that the text is one level larger, it may be safer to use the FONT tag with a SIZE of +1 (<FONT SIZE="+1">) instead of the BIG tag, and use <FONT SIZE="-1"> instead of the SMALL tag to reduce the size by one level.
Nesting BIG tags as in:
<BIG><BIG>text text text</BIG></BIG>
will produce text in a larger font than with just one BIG tag. Similarly,
nesting SMALL tags may produce text in a smaller font than with just
one SMALL tag. Keep in mind that while you are allowed to nest BIG and
SMALL tags, the results are undefined. That is, the results can't be
predicted for all browsers.
Here is a list of some font faces. If some or all are still written in the normal default browser font, then your browser does not support changing the font face in those situations.
<FONT FACE="arial">This is arial font</FONT>
<FONT FACE="algerian">This is algerian font</FONT>
<FONT FACE="braggadocio">This is braggadocio font</FONT>
<FONT FACE="courier">This is courier font</FONT>
<FONT FACE="desdemona">This is desdemona font</FONT>
<FONT FACE="garamond">This is garamond font</FONT>
<FONT FACE="modern">This is modern font</FONT>
Note the following points:
<FONT FACE="arial, courier, modern">
Using this method, if the browsers recognizes the first font listed, it will use that one. If it doesn't recognize the first font listed, it will go to the second font and use it. If it doesn't recognize the second font, it will move to the third one and so on until it finds one it knows or until the list is exhausted. In other words, the browser will use the first one available that it recognizes. If it doesn't recognize any of the listed fonts, the text will simply be displayed in the default mode. If you use this method, you should then write the font faces in order of preference.
<FONT SIZE="4" FACE="arial" COLOR="#FF00FF">text text text</FONT>
Here is an example using BLOCKQUOTE to quote from a book. The HTML coding follows the example.
Be especially careful with fire and fuel. Put out a campfire by dousing it with water. Stir the wet ashes until all sparks are extinguished, then cover the ashes with earth.
Don't carry wooden matches loose in a pocket - if you fall or slide on them they could ignite. Better still, use safety matches. Store fuel containers in the shade and keep them away from flames. Always extinguish a stove or lantern before disconnecting or refilling its fuel tank.
Now here is the complete HTML coding for this example:
<H2 ALIGN="CENTER">CAMPING ETIQUETTE - FIRE SAFETY</H2>
According to the Canadian Automobile Association in their book "Outdoors
Canada" - A Unique and Practical Guide to Wilderness and Wildlife, this
is how you should practice fire safety when camping in the great outdoors:
<BLOCKQUOTE>
<P>Be especially careful with fire and fuel. Put out a campfire by
dousing it with water. Stir the wet ashes until all sparks are extinguished,
then cover the ashes with earth.
<P>Don't carry wooden matches loose in a pocket - if you fall or slide
on them they could ignite. Better still, use safety matches. Store
fuel containers in the shade and keep them away from flames. Always
extinguish a stove or lantern before disconnecting or refilling its
fuel tank.
</BLOCKQUOTE>
Note the following points:
Superscripts are letters or numbers that are raised slightly relative to the normal text as in:
The temperature outside is 78oF.
SUP stands for SUPerscript and if your browser supports superscripts you should see the degree symbol raised slightly. I used the lower case letter "o" for the degree symbol. Here is the HTML coding for the above line:
The temperature outside is 78<SUP>o</SUP>F.
SUP specifies that the enclosed text should be printed in superscript. That is, SUP is a container element and so anything contained between the opening and closing tags will be raised or superscripted.
SUBSCRIPT
Subscripts are letters or numbers that are lowered slightly relative to the normal text as in:
The chemical expression for water is H20.
The HTML coding for this statement is:
The chemical expression for water is H<SUB>2</SUB>0.
SUB specifies that the enclosed text should be printed in SUBscript.
SUP and SUB are often used in mathematical formulas.
At one time these tags were Netscape extension tags only. However, they became
standard in HTML 3.2 for defining both kinds of offset text. So all browsers
support these tags.
Of all the tags given in the title of this section, TT is the most common and it is also the only physical tag. The others are all logical tags. If your browser supports some or all of these elements, you will see them here as follows:
<CITE>This is CITE font</CITE>
<CODE>This is CODE font</CODE>
<SAMP>This is SAMP font</SAMP>
<TT>This is TT font</TT>
<KBD>This is KBD font</KBD>
<VAR>This is VAR font</VAR>
<ADDRESS>
Some of these fonts give identical results - yet each has its own purpose in HTML coding. You should therefore use each element only in the context they were designed for.
Now for a discussion of each element:
CITE
CITE is the logical tag for enclosing a citation - such as the title of a book or magazine. CITE normally prints the citation in italics, the same as <I> does - however, CITE is less widely recognized and less widely used than the "I" element.
Do not use CITE for anything but titles of cited works. For example, in a web page, the person could be discussing HTML and wants to cite a reference. He/she could cite for example:
In the book, HTML CODING, 1997 the writer states that blah, blah, blah ...
The HTML coding for this statement is:
In the book, <CITE>HTML CODING, 1997</CITE> the writer states that blah, blah, blah ...
If you do use CITE for other things, it can confuse others studying your coding and it will also confuse search engine indexers that automatically extract information from your documents. Use <EM> to emphasize in italics and use <I> for text which must appear in italics. In HTML 3.2, there is no tag to mark up short cited phrases. For longer cited phrases, you can use the BLOCKQUOTE element.
CODE
CODE is used to enclose a sample of computer code and also to emphasize pieces of code inside a block of text such as:
In the computer program, the line FOR I=1 to 10 sets up the counter.
The HTML coding for this statement is:
In the computer program, the line <CODE>FOR I=1 to 10</CODE> sets up the counter.
CODE usually gives a monospaced font. If you need to deal with larger blocks of code (several lines of code), it is recommended that you use the PRE element (discussed later in this lesson).
SAMP
SAMP is used to indicate a sample of text which should be used literally. For example,:
The error message General Protection Fault is well known to Windows users.
Here is the HTML coding for this statement:
The error message <SAMP>General Protection Fault</SAMP> is well known to Windows users.
SAMP will usually be rendered in a monospaced font. Now if you must have a monospaced font, do not use SAMP. Instead use TT.
TT
TT stands for TeleType font (also known as Typewriter Text). It is the only font in this group that is considered physical formatting. It is also the monospaced marker that is used most often. It is used to simulate typewriter output. Since TT is a physical element, if a browser does not recognize the tag, it will be ignored. For this reason, it may be better to use CODE or SAMP as these are logical tags that allow the browser to pick the best possible rendering in each case.
KBD
The KBD element is used to indicate text which should be entered by the user. In other words, use KBD in your discussions when you want to indicate that input from the viewer is required. It is usually printed in a monospaced font although some browsers may choose to print it in some other manner such as in bold face. If you want to ensure a monospaced font, use the TT tag instead. Here is an example:
Remember that when asked for a standard installation, type yes at the input prompt.
Here is the HTML coding for this line:
Remember that when asked for a standard installation, type <KBD>yes</KBD> at the input prompt.
VAR
VAR is used to mark up variables. The variables could be marked up in a monospaced font or it could be marked up in some other way such as italics. If you were discussing a computer program for example, you would use VAR to refer to the variables used in the program such as the statement:
In the BASIC program, the variable c is used for the loop counter.
Here is the HTML coding for this line:
In the BASIC program, the variable <VAR>c</VAR> is used for the loop counter.
ADDRESS
The ADDRESS element should be used if you want to enclose contact information - such as addresses and phone numbers. It is also used to enclose the signature file of the author of the web page. In most browsers the text will be rendered in italics, possibly with a slightly indented margin. If the text is not printed in italics, it will be rendered in a monospaced font. Here is an example:
John GilsonThe HTML coding for the above is:
<ADDRESS>John Gilson<BR>
6 Pioneer Place<BR>
Brantford</ADDRESS>
You may have noticed at the beginning of this section when all seven elements were compared, that only the opening and closing ADDRESS tags force line breaks. In other words, the HTML coding:
My street address is <ADDRESS>1327 Orrington</ADDRESS> and my city is <ADDRESS>Chicago.</ADDRESS>
produces:
My street address is
1327 Orrington and my city is Chicago.Closing remarks for this section
<U>text to be underlined</U>
Unless it is very important to emphasize text by underlining, you are
encouraged to avoid this tag. Browsers use underlining to indicate
hyperlinks and many viewers could be confused if they see "links"
that do not work - especially viewers with black and white or
grayscale monitor screens. In fact, many graphical browsers do not support underlined
text since underlined text makes it harder to distinguish the text from
links. Also, Lynx displays text within the EM and STRONG tags with an
underline and so viewers can be confused by further underlining.
The PRE element allows you to keep the original line breaks and spacing that you have inserted into the text in your HTML document. In other words, spaces are not collapsed. This is called preformatted text. Preformatted text is ideal for homemade tables and art. Text inside the PRE tag will be displayed in a monospaced font with some browsers (such as Explorer browsers) displaying the text one level smaller. When building an HTML document in a text editor other than NOTEPAD, be sure to use a monospaced font (such as Courier) so that you can see exactly what the table or art will look like in the browser. NOTEPAD automatically prints text in a monospaced font.
Here is an example of a table done entirely with the <PRE> tag. This table compares two sets of units to measure capacity and their conversion factors in the English system of measurement:
CAPACITY
Liquid Measure Dry Measure
16 fluid ounces = 1 pint 2 pints = 1 quart
2 pints = 1 quart 8 quarts = 1 peck
4 quarts = 1 gallon 4 pecks = 1 bushel
Here is the HTML coding for this table:
<PRE>
<STRONG>CAPACITY
Liquid Measure Dry Measure</STRONG>
16 fluid ounces = 1 pint 2 pints = 1 quart
2 pints = 1 quart 8 quarts = 1 peck
4 quarts = 1 gallon 4 pecks = 1 bushel
</PRE>
Here is a WORD SEARCH puzzle that was also done using the <PRE> tag. To see the HTML coding for this one, just choose SOURCE or DOCUMENT SOURCE from the VIEW menu. This puzzle comes from a magazine called "BIRDS & BLOOMS - a subscription magazine all about birds, flowers and for those who love the great outdoors. The author of this puzzle is Janet Flower of Oregon.
Directions: All 30 of the flower words listed below are found in the puzzle. They appear across, up, down, backward and even diagonally. Find the words and circle them. All the remaining letters will spell the mystery word. The mystery word is given at the end of this lesson.
AMARYLLIS GLOXINIA MARIGOLD
AZALEA GRAPE HYACINTH MUM
BLUE GENTIAN HYACINTH PEONY
CROCUS JOHNNY JUMP UP PETUNIA
DAFFODIL JONQUIL ROSE
DAHLIA LARKSPUR SEGO
DAISY LAVENDER SNAPDRAGON
DAPHNE LILY TULIP
DELPHINIUM LILY OF THE VALLEY VIOLET
GENTIAN LUPINE ZINNIA
L I L Y O F T H E V A L L E Y
Y N O E P N O G A R D P A N S
B L U E G E N T I A N E S A V
P A M A R Y L L I S D A I S Y
U R U P S K R A L R S E G O M
P L I D O F F A D E M U M D U
M J A N D C A L D D A P T L I
U O I A A R Z U A N I I E O N
J N N I H O A P P E N L L G I
Y Q U T L C L I H V N U O I H
N U T N I U E N N A I T I R P
N I E E A S A E E L Z Y V A L
H L P G A I N I X O L G L M E
O R O S E H T N I C A Y H I D
J H T N I C A Y H E P A R G L
Discussion:
<BLINK>text text text</BLINK>
Discussion:
Here is the HTML coding to specify a comment.
<!-- your comment goes here -->
Note the following points:
<!-- BEGIN LINKEXCHANGE CODE -->
.
.
.
<!-- END LINKEXCHANGE CODE -->
Remember that while comments are invisible in the browser, they do appear when viewed in a text editor or when a viewer chooses SOURCE or DOCUMENT SOURCE from the VIEW menu in the browser.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
The WWW Consortium has released a draft version of HTML 4.0 and if your HTML document complies with this draft, the DOCTYPE line must be:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Draft//EN">