More HTML Tags

 

In this section we'll be discussing some more tags to manipulate your text with. We also look at special codes and how colors work in a browser. One of the things we'll also be discussing is fonts. Fonts are the different text types you have on your computer. To see a list of fonts you have available, click on the Start button of Windows and select Settings, then select Control Panel from the pop-up menu. Once the control panel window is open, select the Fonts icon, and a list of available fonts will be displayed. To add a new font, select Install new font... from the File menu of the fonts window. You can add fonts from your local or network drives. They can either be copied to your Fonts folder, or you can use them from their current folder location.

Tags and Meaning

Description

Font Display Tags

<FONT></FONT>

The <FONT></FONT> tags are used to edit your text even further. Every browser has a default font setting, font name, size and color. Unless you have played around with it, the default is Times New Roman 12pt and it's black. The font display tags contain three major attributes, FACE, SIZE and COLOR.
 
The FACE attribute declares the type of font you want to use. The font will only display if your viewer has that font installed on their computer. If the person looking at the page doesn't have the font you specified installed on their computer, then they will only see the default font. So be very judicious in your use of fonts. Arial, Comic Sans MS, Times New Roman and Impact are pretty widely distributed with Windows. Correctly formatted, the font tags will look as follows:

<FONT FACE="IMPACT">This is Impact font</FONT>

And the output will look like this:

This is Impact font

You can hedge your bets a little by specifying more than one font. Consider this:
 
<FONT FACE="ARIAL,HELVETICA,LUCIDA SANS">Hello</FONT>
 
Here's what's happening: the browser looks for ARIAL, if it finds it, it uses it, if not, it goes on to HELVETICA. If it can't find that, it looks for LUCIDA SANS, and if it can't find that it uses the default font.
 
The SIZE attribute equals a number from one to seven, where 7 is the biggest and 1 the smallest.
 
The COLOR attribute can have either the color name or color code as a value. The color name would be something like "green", "red" or "blue", while the color code would be something like "#00FF00".For a more detailed description on color, look at the explanation at the bottom of the page. In the following example both color and size is defined, which also shows that you can use more than one attribute in a tag:

<FONT SIZE="3" COLOR="green">Look at the pretty colors</FONT>

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

Look at the pretty colors

Superscript Above

<SUP></SUP>

The superscript tags are used to display text in the middle of a current text line. Let's say you want to display the address 45th Avenue but want it displayed like this 45th Avenue, with the "th" in the middle of the current text line, you will use the <SUP></SUP> tags as follow:

45<SUP>th</SUP> Avenue

Subscript Below

<SUB></SUB>

The <SUB></SUB> tags is exactly like the <SUP></SUP> tags, but instead of displaying the text more to the top of the current text line, it displays the text just below the current text line. Lets say you want to display the following mathematical equation A 2 = 45, but you want the "2" displayed just below the "A", then the format will look as follows:

A<SUB>2</SUB> = 45

The result will look like this:

A2 = 45

Scrolling Tags

<MARQUEE></MARQUEE>

The <MARQUEE></MARQUEE> tags scroll your defined piece of text or image across the screen. The following attributes can be defined for the scrolling tags: WIDTH, HEIGHT, BGCOLOR, LOOP, ALIGN, BEHAVIOR, SCROLLDELAY and SCROLLAMOUNT. Note however that this is also one of those tags that work fine in Internet Explorer, but not in Netscape Navigator for some reason. The tags are defined as follows, note the following example is the least amount of definition required for the <MARQUEE></MARQUEE> tags:
 
<MARQUEE WIDTH="55%">Text or image you want scrolling across the screen</MARQUEE>
 
If your browser supports the <MARQUEE></MARQUEE> tags, this is what the output will look like:

Text or image you want scrolling across the screen

The WIDTH and HEIGHT attributes define the horizontal and vertical size of the scrolling block, both of these can be entered as a percentage (WIDTH="50%") or pixel (WIDTH="100") value.

The BGCOLOR attribute defines the back ground color of the scrolling block, and accepts both color names (BGCOLOR="GREEN") and color codes (BGCOLOR="#00FF00").

LOOP does just what it says. This attribute specifies the amount of times the text should scroll across the scroll bar. If left out, the text will scroll an unlimited amount of times.

The ALIGN attribute can have the following values: TOP, MIDDLE or BOTTOM. This attribute is designed to align text that comes after or before a scroll bar with a certain part of the scroll bar itself.

The BEHAVIOR attribute controls the scrolling movement of the text inside the scrolling block, and accepts three values: SCROLL and ALTERNATE.

SCROLL makes the text move across from right to left in the scrolling block and is also the default if not specified. Correctly formatted it should look like this:

This is marquee with behaviour equal to SCROLL

ALTERNATE makes the text bounce from left to right in the scrolling block. Correctly formatted it should look like this:

This is marquee with behaviour equal to ALTERNATE

SCROLLDELAY specifies the speed at which the text will scroll across or within the scroll bar.

SCROLLAMOUNT specifies the amount of spaces or characters the text within the scroll bar should advance at one time. In other words, the lower this value the smoother the text will scroll across or within the scroll bar.

The following example is the <MARQUEE></MARQUEE> tags,defined with all it's attributes:

<MARQUEE WIDTH="100%" HEIGHT="20" BGCOLOR="WHITE" LOOP="10" ALIGN="MIDDLE" BEHAVIOR="ALTERNATE" SCROLLDELAY="10" SCROLLAMOUNT="1">Scrolling Text</MARQUEE>

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

Scrolling Text

One more attribute that can be set for the <MARQUEE></MARQUEE> tags, is the STYLE attribute. This allows you to place a border around the scroll bar. The STYLE attribute can have the following values: BORDER, BORDER-LEFT, BORDER-RIGHT, BORDER-TOP and BORDER-BOTTOM. The BORDER value sets all four sides of the scroll bar. This means that if you only want a line on the bottom of the scroll bar you will specify the BORDER-BOTTOM value. The following example shows how to define the STYLE attribute.

<MARQUEE WIDTH="80%" STYLE="BORDER: 1px solid">Scrolling Text</MARQUEE>

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

Scrolling Text

As you probably noted, the value of the STYLE attribute wasn't just set to BORDER but BORDER: 1px solid. The code after the colon defines the width of the border. Thus if you wanted to make the border thicker you would have set the STYLE attribute to BORDER: 5px solid, like this:

<MARQUEE WIDTH="80%" STYLE="BORDER: 5px solid">Scrolling Text</MARQUEE>

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

Scrolling Text

The other values for the STYLE attribute: BORDER-LEFT, BORDER-RIGHT, BORDER-TOP and BORDER-BOTTOM, are defined exactly the same as the BORDER value. Only difference is, it only draws the lines you define. In other words, if you only want a line at the bottom of the scroll bar, your code will look as follows:

<MARQUEE WIDTH="80%" STYLE="BORDER-BOTTOM: 1px solid">Scrolling Text</MARQUEE>

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

Scrolling Text

But let's assume you only want a right and a left border, then you will define the scroll bar like this:

<MARQUEE WIDTH="80%" STYLE="BORDER-LEFT: 1px solid; BORDER-RIGHT: 1px solid">Scrolling Text</MARQUEE>

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

Scrolling Text

Note however the semi colon ( ; ) which separates the two values BORDER-LEFT and BORDER-RIGHT. Also remember that as soon as you define the BORDER value with all of these, it will override all the other values and draw a full border around the scroll bar. So only BORDER-LEFT, BORDER-RIGHT, BORDER-TOP and BORDER-BOTTOM can be used in conjunction with each other in this instance.

Prohibiting Tags

<XMP></XMP>

The <XMP></XMP> tags ensure that any content inside the container is displayed without any processing. In this way, any HTML inside the container is simply displayed as regular text rather than treated as HTML. For instance:

<XMP><FONT SIZE="6">Hello World</FONT></XMP>

Will have the following output:

<FONT SIZE="6">Hello World</FONT>

Comment Tags

<!-- -->

A comment can be placed anywhere in the document and the browser will ignore everything inside the brackets. The comment must start with <!-- and end with -->. You can even put other HTML tags in a comment and they will be ignored. The browser will just keep ignoring everything until it sees a -->. The comment is just there for your own benefit so that you can understand your code better. A comment would look as follows:

<!-- Hi mom -->

 

 

Special Codes

 

Apart from tags, there are also some special codes one can use to produce a desired affect. Take spaces for instance, the browser won't recognize more than 1 space at one time. Consider the following:

<BODY>
This     must     be      spaced     out
</BODY>

The output in your browser for this however will look like this:

This must be spaced out

There is a nifty little code that means "space" to the browser: &nbsp;. Now lets do the same example as before, but this time use the space code:

<BODY>
This
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;must&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;be
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;spaced&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;out
</BODY>

And the output in your browser for this will look as follows:

This     must      be     spaced     out

The ampersand ( & ) means we are beginning a special character, while the semi colon ( ; ) means ending a special character, and the letters in between are an abbreviation for what it's for. There are quite a few of these special characters. Note, the codes are case sensitive, meaning type the code exactly as it is listed below. You don't need to use them all the time, just when typing the real character would confuse the browser. The following table lists the codes.

Code Result Description
&nbsp;   non-breaking space
&lt; < less-than symbol
&gt; > greater-than symbol
&amp; & ampersand
&quot; " quotation mark
&shy; ­ soft hyphen
&Agrave; À capital A, grave accent
&iuml; ï small i, dieresis/umlaut
&agrave; à small a, grave accent
&ETH; Ð capital Eth, Icelandic
&Aacute; Á capital A, acute accent
&eth; ð small eth, Icelandic
&aacute; á small a, acute accent
&Ntilde; Ñ capital N, tilde
&Acirc; Â capital A, circumflex
&ntilde; ñ small n, tilde
&acirc; â small a, circumflex
&Ograve; Ò capital O, grave accent
&Atilde; Ã capital A, tilde
&ograve; ò small o, grave accent
&atilde; ã small a, tilde
&Oacute; Ó capital O, acute accent
&Auml; Ä capital A, dieresis/umlaut
&oacute; ó small o, acute accent
&auml; ä small a, dieresis/umlaut
&Ocirc; Ô capital O, circumflex
&Aring; Å capital A, ring
&ocirc; ô small o, circumflex
&aring; å small a, ring
&Otilde; Õ capital O, tilde
&AElig; Æ capital AE ligature
&otilde; õ small o, tilde
&aelig; æ small ae ligature
&Ouml; Ö capital O, dieresis/umlaut
&Ccedil; Ç capital C, cedilla
&ouml; ö small o, dieresis/umlaut
&ccedil; ç small c, cedilla
&Oslash; Ø capital O, slash
&Egrave; È capital E, grave accent
&oslash; ø small o, slash
&egrave; è small e, grave accent
&Ugrave; Ù capital U, grave accent
&Eacute; É capital E, acute accent
&ugrave; ù small u, grave accent
&eacute; é small e, acute accent
&Uacute; Ú capital U, acute accent
&Ecirc; Ê capital E, circumflex
&uacute; ú small u, acute accent
&ecirc; ê small e, circumflex
&Ucirc; Û capital U, circumflex
&Euml; Ë capital E, dieresis/umlaut
&ucirc; û small u, circumflex
&euml; ë small e, dieresis/umlaut
&Uuml; Ü capital U, dieresis/umlaut
&Igrave; Ì capital I, grave accent
&uuml; ü small u, dieresis/umlaut
&igrave; ì small i, grave accent
&Yacute; Ý capital Y, acute accent
&Iacute; Í capital I, acute accent
&yacute; ý small y, acute accent
&iacute; í small i, acute accent
&THORN; Þ capital Thorn, Icelandic
&Icirc; Î capital I, circumflex
&thorn; þ small thorn, Icelandic
&icirc; î small i, circumflex
&szlig; ß small sharp s, German sz
&Iuml; Ï capital I, dieresis/umlaut
&yuml; ÿ small y, dieresis/umlaut
&plusmn; ± plus-or-minus sign
&iexcl; ¡ inverted exclamation mark
&sup2; ² superscript two
&cent; ¢ cent sign
&sup3; ³ superscript three
&pound; £ pound sign
&acute; ´ acute accent
&curren; ¤ general currency sign
&micro; µ micro sign
&yen; ¥ yen sign
&para; pilcrow (paragraph sign)
&brvbar; ¦ broken (vertical) bar
&middot; · middle dot
&sect; § section sign
&cedil; ¸ cedilla
&uml; ¨ umlaut/dieresis
&sup1; ¹ superscript one
&copy; © copyright sign
&ordm; º ordinal indicator, male
&ordf; ª ordinal indicator, fem
&raquo; » angle quotation mark, right
&laquo; « angle quotation mark, left
&frac14; ¼ fraction one-quarter
&not; ¬ not sign
&frac12; ½ fraction one-half
&frac34; ¾ fraction three-quarters
&reg; ® registered sign
&iquest; ¿ inverted question mark
&macr; ¯ macron
&times; × multiply sign
&deg; ° degree sign
&div; ÷ division sign

 

 

Colors

 

Colors, not the easiest thing to control unless you live in a hexadecimal world. Hex-a-what? Well, we are used to counting in base ten, because that's how many fingers we have. The designers of the original HTML decided to work in base sixteen because it all made sense to them (not because they had sixteen fingers). Without sounding too much like a maths lesson, the colors in HTML are made up of 256 shades of Red, Green and Blue. This can make up a possible total of 16,777,216 different colors. Let's take a look at the color code "#RRGGBB".

To start with, we can split up the statement like so:

#

RR

GG

BB

Tells the browser to expect a number from within the HTML document.

The Red component. A number between 0 and 256.

The Green component. A number between 0 and 256.

The Blue component. A number between 0 and 256

OK, but how do we put the number 256 into two characters? You need to translate the number to hexadecimal. To count from zero to sixteen in hexadecimal you need to use some letters as well like this:

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

Decimal Base 10

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

Hexadecimal Base 16

So 0 looks like 00 and 256 look like FF. Totally confused? Then look at the following:

Black = "#000000" - no red, green or blue
White = "#FFFFFF" - full red, green and blue
Red = "#FF0000" - full red, no green or blue
Green = "#00FF00" - no red, full green and no blue
Blue = "#0000FF" - no red or green but full blue

You can see that the green, in particular, is difficult to see. To make it darker we just lower the value of the green component:

Dark Green = "#006600" - no red, about 40% green and no blue

Other colors are made up of combining the different shades of the red, green and blue components:

Yellow = "#FFFF00" - full red and green, no blue
Pink = "#FF00FF" - full red, no green and full blue
Cyan = "#00FFFF" - no red, full green and blue

But how does one convert from decimal which in this case can be between 0 and 256, to hexadecimal? You can either use the following formula:

Let's say you decided on decimal 110 for the red component.

Divide 110 by 16, that equals 6 remainder 14.
Now divide the answer excluding the remainder with 16, in this case 6 divided by 16, which equals 0 remainder 6.
Once the answer excluding the remainder equals 0, write the remainders down from the bottom up. So that would make 6 and 14, but 14 in hexadecimal is "E", so the hexadecimal for decimal 110 is 6E

In short, decimal 155 will be converted to hexadecimal as follows:

155 / 16 = 9 remainder 11 (B)
9 / 16 = 0 remainder 9
decimal 155 = hexadecimal 9B

If the decimal being converted is less than 16, the hexadecimal answer will be incorrectly computed as follows:

10 / 16 = 0 remainder 10 (A)
decimal 10 = hexadecimal A

In this case the answer is already zero after the first divide, but for hexadecimal the answer must be 2 characters long, so in the case where the decimal value being converted is less than 16, a leading zero is added, like so:

10 / 16 = 0 remainder 10 (A)
decimal 10 = hexadecimal 0A

Also keep in mind that the decimal value being converted can not be greater than 255.

But if this is all to complicated for you, just use the calculator that came with Windows and make sure it's set to scientific. If not, select Scientific in the View menu of your calculator, then just enter your decimal value and select the Hex radio button to convert the decimal value to hexadecimal.

But if that is too much work, just click here, for a color chart colors.gif (1041 bytes) with all the major colors.

The following is an example with all the tags you have seen here. Plus, I am also going to demonstrate how to combine tags to achieve a desired affect.

<HTML>
<HEAD>
<TITLE>More Tag Examples</TITLE>
</HEAD>
<BODY>
<FONT SIZE="10" COLOR="#0000FF">More Tag Examples</FONT>
<P>
<MARQUEE WIDTH="70%" STYLE="BORDER: 1px solid">
<B>
<FONT SIZE="5" COLOR="#006600">
Welcome to the MATHS page
</FONT>
</B>
</MARQUEE>
</P>
<P>
Try and solve the following equation in eight steps or less, where X =
1&frac14 and Y = 2&frac12:
<BR>
<FONT COLOR="#000066">
<B>
X<SUB>2</SUB> + Y<SUB>4</SUB> = X<SUB>4</SUB> + Y<SUB>2</SUB>
</B>
</FONT>
</P>
<P>
Send your answer to the following address. The first received correct
answer will win that dream car.
<BR>
<FONT COLOR="#000066">
<B>
Math Competition<BR>
45<SUP>th</SUP> Avenue<BR>
Somewhere<BR>
Someplace<BR>
2000
</B>
</FONT>
</P>
</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.

As you can see from the example above, I have used the <FONT></FONT>, <B></B> and <MARQUEE></MARQUEE> tags together to create a scroll bar with colored bold text scrolling inside it. You can combine any HTML tags together as long as you remember that the tags should be nested, eg. (<STRONG><STRIKE></STRIKE></STRONG>) and not overlapping (<STRONG><STRIKE></STRONG></STRIKE>).

output.gif (894 bytes) Click here to go to the personal homepage example, for this section of the tutorial. 

 

[Next Section - List 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