2. Style Tags

HTML (HyperText Markup Language) is a FORMATTING language as opposed to a PROGRAMMING language. That means that it deals with the "look" of things on the computer screen rather than with variables, computation, etc. It has a symbolic syntax like any computer language. You need to learn what those symbols mean, what they cause the browser to do, and the way to write them, in order to make text look like you want it to on the screen. You will start doing that with this lesson.

HTML uses a syntax composed of letters or words inside "less than" and "greater than" symbols (<. . .>) called "tags." For example <B> is the tag which tells the computer to make all text that comes after this symbol BOLD.

That's nice, but if you don't want to have everything after the <B> bold, you have to have a way to stop it. HTML provides a "stop sign" by using the "/" inside the <> and before the symbol. That is, by using the symbol </B> you are telling HTML that the "bold" sytle should stop right here.

Example

Suppose the following sentence with the BOLD tags is put into an HTML file.

The <B>University of Redlands </B> presents the <B>Feast of Lights </B> each Christmas season.

When it is viewed with a browser it will look like this.

The University of Redlands presents the Feast of Lights each Christmas season.

Since you are viewing this in a browser, you can probably guess that all I did was copy the sentence with the BOLD tags into the file you are reading, and the browser interpreted them making University of Redlands and Feast of Lights bold. If you guessed that, then you were right, but there is another mystery. Think about what you see in the <B> code example agove, and later in this lesson, I will reveal the secret.

The most common of the Style tags are those for BOLD, ITALIC, UNDERLINE, BLINK, SUBSCRIPT, and SUPERSCRIPT. There are others, and I will give you a list of those later.

You have seen how the syntax for BOLD works. The entire list of syntaxes for the tags for the styles above are:

BOLD <B> . . . </B>
ITALIC <I> . . . </I>
UNDERLINE <U> . . . </U>
BLINK <BLINK> . . . </BLINK>
SUBSCRIPT <SUB> . . . </SUB>
SUPERSCRIPT <SUP> . . . </SUP>

Combining them all into a single sentence would look something like this:

The <B>University</B> of <I>Redlands</I>presents the <U>Feast</U>of <BLINK>Lights</BLINK> <SUP>each</SUP>Christmas <SUB>season.</SUP>

As interpreted by the bowser it looks this way.

The University of Redlandspresents the Feast of Lights each Christmas season.

Of course you can make something bold, underlined, blinking by just compounding the style tags as below.

<B><U><BLINK>bold, underlined, blinking</BLINK></U></B>

It all depends of the kind of emphasis you wish to give a particular piece of text.

It doesn't really matter what order you put the style tags in, since they only work on the text, not each other. Good form, however, demands that the closing tags be in reverse order of the opening ones. That is called "nesting" the tags and makes them easier to find for editing.

Also, you have probably noticed that the tags have all been in upper case letters. HTML doesn't care about the case of the letters in a tag. At least it isn't supposed to. In later lessons you will see a couple of apparent exceptions. However, if you always do them in upper case, they are easier to spot in the code when you are doing editing.

By now you are probably pretty sick of seeing those things blinking. It is good to use BLINKING very judiciously. Sometimes when you have added something new to a page, and you wish to make sure people notice, you use it. Other than that, it is just an irritant.

I promised you some other style tags, so here they are with what they do.

Less Used Style Tags

Tag Name Tag SyntaxTag Results
ADDRESS <ADDRESS> ... </ADDRESS>
Marks text as an address. Generally used to specify the author and providesa means of contact.
CITE <CITE> . . . </CITE>Marks text as the title of a book, film, etc. Puts it in italics
CODE <CODE> . . . </CODE>Marks text as computer code. Does it in a non-proportional (fixed width) font.
DEFINITION <DFN> . . . </DFN>Marks the text as a word being defined. Does it with italics in IE, but seems to do nothing in Netscape.
EMPHASIS <EM> . . . </EM>Marks the selected text as needing emphasis. Puts it in italics..
FIXED WIDTH <TT> . . . </TT>Marks the selected text to be shown in a non-porptional (fixed width) font.
KEYBOARD <KBD> . . . </KBD>Marks text for keyboard entry. Puts it in a non-porportional (fixed width) font.
SAMPLE <SAMP> . . . </SAMP>Marks the text for comuter status messages. Puts it in a non-porportional (fixed width) font.
STRONG EMPHASIS <STRONG> . . . </STRONG>Marks the text for strong emphasis. It puts it in bold
VARIABLE <VAR> . . . </VAR>Marks the text as being a variable. Puts it in italics

Earlier I spoke of a question you should be asking yourself about what you saw in the examples of code. That question is, "How did I get the <B> . . . </B> in the example to be not "interpreted" when the HTML file was displayed in the browser?

Clearly there are a number of symbols reserved for the syntax of HTML or are not on the standard computer keyboard. Since there are times they must be used, there is a set of special symbols for them that is recognized by HTML. Thes are not the letter or symbol themselves. They are "Special Characters" and are of the form "&xxx;"(the CHARACTER notation) or "&#xxx;" (the DECIMAL notation) where the xxx in the CHARACTER notation is some abbreviation of the symbol and in the DECIMAL notation, the xxx is the ascii number of the symbol. In order to put > in an html page you type &gt; (CHARACTER notation) or &#60; (DECIMAL notation) and for < you type &lt; or &#;62;. You have probably surmised that "gt" stands for "greater than" and "lt" stands for "less than for these two symbols."

A complete list of the characters and their ascii numbers may be found at:

http://utopia.knoware.nl/users/schluter/doc/tags/index.html

You can't go directly to the page with the "special character" codes on it. There is a "dropdown" menu at the top of the page which has =====Tags===== on it. Down near the bottom of that menu is the choice "Character set." Select that, and the page you need will appear. Unfortunately, the CHARACTER notations are not complete, so you will have to rely on the ascii number (DECIMAL notation) for some symbols.

Now open your text editor or word processor and type the answers to the following questions into it. Save the document as HTML Exercises_2.

Exercises 2

Write HTML style tags which make the following sentences appear formatted as below.

1. The quick, brown fox jumped over a lazy dog's back has the adjectives in the sentence in bold and the articles in italic.

2. Ernest Hemingway wrote many books, among which are The Sun Also Rises and Farewell to Arms. He also published many short stories in the New Yorker and Life.

3. Mother was very agitated. She asked, "Why would you do such a thing? Don't you know that Turkeys can't fly?"

4. Niña in Spanish, eté in French and Fahrvergnügen in German mean "young girl," "summer," and "driving enjoyment" respectively. Each contains a letter with an accent common in those languages.
(You will need to look up and use the HTML code for "special characters" in order to use the special or accented letters.)

If you want to see my answers, click here.

After reading the answers, to put things back the way they were, use the BACK button or scroll down to the link at the bottom of the page of answers.