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> |
<FONT FACE="IMPACT">This is Impact font</FONT>
This is Impact font
<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> |
A<SUB>2</SUB> = 45 The result will look like this: A2 = 45 |
| Scrolling Tags <MARQUEE></MARQUEE> |
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:
ALTERNATE makes the text bounce from left to right in the scrolling block. Correctly formatted it should look like this:
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: 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: 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: 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: 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: 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:
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: . Now lets do the same example as before, but this time use the space code:
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 |
| | non-breaking space | |
| < | < | less-than symbol |
| > | > | greater-than symbol |
| & | & | ampersand |
| " | " | quotation mark |
| ­ | | soft hyphen |
| À | À | capital A, grave accent |
| ï | ï | small i, dieresis/umlaut |
| à | à | small a, grave accent |
| Ð | Ð | capital Eth, Icelandic |
| Á | Á | capital A, acute accent |
| ð | ð | small eth, Icelandic |
| á | á | small a, acute accent |
| Ñ | Ñ | capital N, tilde |
| Â | Â | capital A, circumflex |
| ñ | ñ | small n, tilde |
| â | â | small a, circumflex |
| Ò | Ò | capital O, grave accent |
| Ã | Ã | capital A, tilde |
| ò | ò | small o, grave accent |
| ã | ã | small a, tilde |
| Ó | Ó | capital O, acute accent |
| Ä | Ä | capital A, dieresis/umlaut |
| ó | ó | small o, acute accent |
| ä | ä | small a, dieresis/umlaut |
| Ô | Ô | capital O, circumflex |
| Å | Å | capital A, ring |
| ô | ô | small o, circumflex |
| å | å | small a, ring |
| Õ | Õ | capital O, tilde |
| Æ | Æ | capital AE ligature |
| õ | õ | small o, tilde |
| æ | æ | small ae ligature |
| Ö | Ö | capital O, dieresis/umlaut |
| Ç | Ç | capital C, cedilla |
| ö | ö | small o, dieresis/umlaut |
| ç | ç | small c, cedilla |
| Ø | Ø | capital O, slash |
| È | È | capital E, grave accent |
| ø | ø | small o, slash |
| è | è | small e, grave accent |
| Ù | Ù | capital U, grave accent |
| É | É | capital E, acute accent |
| ù | ù | small u, grave accent |
| é | é | small e, acute accent |
| Ú | Ú | capital U, acute accent |
| Ê | Ê | capital E, circumflex |
| ú | ú | small u, acute accent |
| ê | ê | small e, circumflex |
| Û | Û | capital U, circumflex |
| Ë | Ë | capital E, dieresis/umlaut |
| û | û | small u, circumflex |
| ë | ë | small e, dieresis/umlaut |
| Ü | Ü | capital U, dieresis/umlaut |
| Ì | Ì | capital I, grave accent |
| ü | ü | small u, dieresis/umlaut |
| ì | ì | small i, grave accent |
| Ý | Ý | capital Y, acute accent |
| Í | Í | capital I, acute accent |
| ý | ý | small y, acute accent |
| í | í | small i, acute accent |
| Þ | Þ | capital Thorn, Icelandic |
| Î | Î | capital I, circumflex |
| þ | þ | small thorn, Icelandic |
| î | î | small i, circumflex |
| ß | ß | small sharp s, German sz |
| Ï | Ï | capital I, dieresis/umlaut |
| ÿ | ÿ | small y, dieresis/umlaut |
| ± | ± | plus-or-minus sign |
| ¡ | ¡ | inverted exclamation mark |
| ² | ² | superscript two |
| ¢ | ¢ | cent sign |
| ³ | ³ | superscript three |
| £ | £ | pound sign |
| ´ | ´ | acute accent |
| ¤ | ¤ | general currency sign |
| µ | µ | micro sign |
| ¥ | ¥ | yen sign |
| ¶ | ¶ | pilcrow (paragraph sign) |
| ¦ | ¦ | broken (vertical) bar |
| · | · | middle dot |
| § | § | section sign |
| ¸ | ¸ | cedilla |
| ¨ | ¨ | umlaut/dieresis |
| ¹ | ¹ | superscript one |
| © | © | copyright sign |
| º | º | ordinal indicator, male |
| ª | ª | ordinal indicator, fem |
| » | » | angle quotation mark, right |
| « | « | angle quotation mark, left |
| ¼ | ¼ | fraction one-quarter |
| ¬ | ¬ | not sign |
| ½ | ½ | fraction one-half |
| ¾ | ¾ | fraction three-quarters |
| ® | ® | registered sign |
| ¿ | ¿ | inverted question mark |
| ¯ | ¯ | macron |
| × | × | multiply sign |
| ° | ° | degree sign |
| ÷ | ÷ | division sign |
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:
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:
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.
In short, decimal 155 will be converted to hexadecimal as follows:
If the decimal being converted is less than 16, the hexadecimal answer will be incorrectly computed as follows:
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:
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
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.
| 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>).
| Click here to go to the personal homepage example, for this section of the tutorial. |
[Next Section - List Tags] [Back To Index Page]