HTML Tutorials by HITMILL

Understanding the HTML Document

Maribeth C. Yarnell

For those who are ready to delve into HTML, and would like to have an understanding of how all those tags work, this is your introduction. It is also a good introduction to SGML, as HTML is a subset of SGML. There are many great free resources on the internet for learning web programming (and scripting) --I've given you some of the very best below-- but this first big bite just wasn't available, so here you go...

Start at the Beginning

HTML is a markup language, meaning that tags are used to mark where and what kind of formatting will affect the data. Most of the tags require you to start, then stop the use of a certain kind of formatting. For example,
 
<B>
turns ON bold when preceding text
 
</B>
turns OFF bold if it has been turned on. Any intervening text will be shown in bold text.

HTML files must be ASCII TEXT files in order to work. Therefore, if you create in a word processing program, you MUST save as a text file before viewing in a browser.
Your first line in any HTML document to be used publically should be:
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

This is read as Document Type is HTML PUBLIC as defined by the W3C (World Wide Web Consortium), the Document Type Definition [DTD] is HTML (Hyper Text Markup Language), and compliant with version 4.0, but Transitional, because we may have some older version tags left over in the document somewhere. Then we specify the English language with "EN"

This line goes first, above the opening     <HTML>   tag.

Then we have the opening

<HTML> 

Instructions in the HEAD of the HTML Document

The opening HTML tag is followed by the opening

<HEAD> 


then the opening

<TITLE> 
followed by the name of the page which displays in the window's top bar, (not in the body of your page)

In this case, I called this page HTML Coach, --notice it in the top bar

Now we will close the Title tag by typing the tag with a slash before the text;


</TITLE>
All tags that require closure, will be closed in this way.

(The closing HTML tag will be the last tag on the page.)




Next comes our META tags, still within the HEAD area, that is, between the opening and closing HEAD tags. META tags tell the browsers and search engines useful information. The content type and character set are the most important META tag, and helps browsers more easily recognize your page.
 
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
The META nametag "description" lets you put in a page purpose, such as we did here, "Learning HTML" or even "Family Homepage"
 <META name="description" content="Understanding HTML"> 
The META nametag "Keywords" is the most useful if you want people searching the internet to find your page.
 
<META name="keywords" content="HTML, tags, HTML scripting, HTML how-to">

Now you can close the HEAD tag with

 
</HEAD>

There are other META tags, but these are a good starting point, and even these are not required.




Creating and Formatting the BODY of the HTML page

The next line is to designate the beginning of the body of the document or HTML page:
<BODY>
But while we're here, we can designate a few other things, such as text color and background color for the whole page. I believe that easiest-to-use background is white, and recommend limited use of anything other than black for text... but for the sake of instruction, we'll show how to specify page background colors (although white will usually default).

COLOR

Color to be displayed by the browser (as opposed to separate pictures) is SET using "hex code" settings. These colors are set using six digits or characters with a hashmark or pound sign # and enclosed in quotation marks. This is the way all browser colors will be set, so you'll want to be familiar with the format. Now we will specify black text and add background color to the BODY tag. (This page has a white background, so the hex code is "#FFFFFF")

I've included a hex-code cheater-chart at the bottom of this page so you can pick some colors by double clicking on the characters in a block and using copy-paste to designate your colors in your HTML.

 
<BODY TEXT="#000000" BGCOLOR="#FFFFCC">
See the color selector chart at the end of this page.
colors
00=least (these are zeros)
FF= most
first position of 2 characters is RED
second position of 2 characters is GREEN
third position of 2 characters is BLUE
FFFFFF = WHITE
000000 = BLACK
0000FF = BLUE
FF0000 = RED
FFFF00 = YELLOW
00FF00 = GREEN
00FFFF = CYAN
EEEEEE = LIGHT GREY
To be compliant with HTML 4.0 Transitional, be sure to use the leading hashmark (pound sign) and place between double quotation marks.)

A limited group of colors may be designated by color-name:
black, maroon, green, olive, navy, purple, teal, gray, silver, red, lime, yellow, blue, fuschia, aqua, white.

These colors are very strong, and are not recommended as background for legible text. Be sure to use the double quotes.

See color chart at the bottom of the page.







In the simplest of pages, we might now use a HEADING tag to announce our page. HTML basic headings are available in 6 sizes with H1 being the largest and H6 the tiniest. All are bold, in a default Roman font.
 <h1>Welcome to My Web!</h1>
produces

Welcome to My Web

Notice that turned the heading tag on, then turned it off with a slash. The browser default for headings is left justified, but maybe you'd like that heading to be centered? Just add that instruction align="center" to your heading.
 <h1 align="center">Welcome to My Web!</h1>
The simple
 </h1>
still turns the heading OFF.

If a whole paragraph leaves too much space between lines, you can use a BREAK tag to just break to the next line without skipping a line:
 <BR>
SAMPLE:

This is my line of text.

This is a second paragraph. Now we will break a paragraph at a specific point
and put part of it on
other lines.

A paragraph tag

 
<p>
is best used for general narrative text. (Upper or lowercase does not matter.)
NOTE:This page is produced in a slightly more complicated way, so the default browser text is not being used for most of the instructions. I will use default text in the examples so that you will see what you expect to see.



Remember:
DO NOT USE this document's SOURCE HTML.

I have done special markup to be able to show you common basic scripting with expected results. The source has been somewhat manipulated.

Use the SOURCE scripting in the Template for HTMLcoach (filename: MAKEPAGEtemplate.htm)
OR Template for HTMLcoach (filename: MAKEPAGEtemplate.txt)




There are many ways to control text in HTML including:
  • Lists: unordered bulleted lists, numbered lists, and special treatment lists
  • tables - probably the most powerful tool for simple pages.
  • stylesheets and inline styles adhering to cascading stylesheet design.
TABLES:
The MAKEPAGEhtml.txt template page shows sample code for tables and lists that you an experiment with, and the template is built within a table for good display purposes. One issue to remember when building pages using tables is that the page will not fully display until the first ENTIRE table is displayed. Therefore, it is wise to break long pages into several tables, so users can be looking at the first material while additional materials are loading.

FONTS:
You may be tempted to use some fancy fonts that your find on your system when you add a nifty graphics package. ONLY use unusual fonts if you are creating a graphic. Otherwise, browsers convert your delightful fancy font face into something "related" that your viewer has on their system.

You need to know two terms about type faces:
Serif: The characters have tiny flourishes, decorations, or little extra lines on them. That little "foot" or base under an "r" is a good example. Times New Roman and Times are Serif fonts. Using the designation "Serif" will provide a generic Serif face.

Sans Serif:The characters have no extra lines. Notice the "r" has only a vertical line extending to the baseline. Arial and Helvetica are Sans Serif fonts. (from the French, "without Serif")

You get the benefit of a default monospaced font when you use special HTML, such as
 <PRE>
for "preformatted" and
 <TT>
for "typewriter."

Monospace is useful in aligning characters, such as completing a list of financial entries.

The following type faces are installed with Internet Explorer on both PC and Macintosh operating systems.

Sans serif: Arial, Arial Narrow, Arial Black, Arial Black,Verdana Serif: Georgia, Times New Roman Monospace: Andale Mono, Courier New

Since these are Microsoft's True Type Fonts, the generic font faces are likely to be used when viewers are using Netscape, for example. I've noticed that many of the older Macs use Helvetica and Times, so I include those as options when I specify fonts. I've also noticed that Verdana is very large and round. If I'm tight for spacing, I don't include Verdana. If I want to show off the size, I use Verdana, realizing that not all viewers will see Verdana, but might see one of the less preferred options.




For quick starts, we will go on to images:

The primary forms of graphic images used on web pages are the Compuserve Graphic Interchange Format - .gif images for drawings and simple artwork, and Joint Photographic Export Group - .jpg for photographs.

.gif files can also be made "transparent" so that a peculiar shape can look as if it sits right on a colored or sophisticated background, and the .gif can be "animated" - switching between drawings in slightly different positions or configurations so they look like they are moving. .jpg files do not have this versatility, but show photos sharply with great color control in small files.

Bitmap files, extension .bmp, will often display in the more popular browsers, but can be slower to load.
File size can be a really big issue if users are on dial-up internet access.
The following graphic, designed for the Air Capital Barbershop chorus, is already on the server, so we'll use it for our example:

 <IMG SRC="wings4acc_432x108.jpg" width="432" height="108" alt="JPG 432px-108px">



This code is read as IMAGE SOURCE equals URL/filename.extension WIDTH in pixels, HEIGHT in pixels, ALT is a title to display especially if the user is not seeing the graphic. I include the native graphic size in pixels in my filenames for MY information is design, and make ONLY minor size adjustments if necessary when displaying.

Remember that you do NOT want to make radical size changes in the browser, because the graphic will become very choppy - even going from a large size to a smaller display.

images

Insert an image by reference and define size by height and width. Defining final size in the document tells the browser how much space to allow for the graphic, and thereby to allow the rest of the page to load while the potentially slow image is still downloading.

It is often wise to put graphic files together in a single subdirectory:
most use a directory named "images" at the base URL.
GOOD IDEA to NOT keep your visitors waiting while a big picture for graphic is downloading, if you have text they can read.
When the image is in the same directory as the HTML document calling it, and we choose to center this graphic, so the opening and closing <center> tag is used:
 
<center><IMG SRC="wings4acc_432x108.jpg" width="432" height="108" alt="JPG 432px-108px"></center>



JPG 432px-108px




When the image is in an images directory at the same level as the HTML document calling it:
 <IMG SRC="images/wings4acc_432x108.jpg" width="432" height="108" alt="JPG 432px-108px">

When the image is in an images directory at a level closer to the root when the HTML document calling it is in a subdirectory, the 2 dots and slash indicate a directory shift toward the root before entry into the images directory:
 
<IMG SRC="../images/wings4acc_432x108.jpg" width="432" height="108" alt="JPG 432px-108px">





RESOURCES

The WERBACH BAREBONES document will be used for quick reference.
You can download from this site:
text file to keep open while editing pages.
zip file with text and formatted versions, and commentary
or you can go to Werbach's site. Lots of advertising, but he deserves anything he can get for all the work and the contribution he's made over the years:
http://werbach.com/barebones/


Dr. Joe Burns' HTML Goodies site (and book of the same name) is highly recommended for quickly getting up to speed on the entire breadth of HTML related programming, but it does take some time to be able to use the site to it's fullest. Be patient, walk the tutorials at your pace, and become an expert. http://www.htmlgoodies.com/

If acronyms or terminology get you down, or just peak your curiousity, one great resource is from New Zealand The Motive Internet Glossary, and they'll accept your suggestions for additions.

GOODIES
JARGON
CHARS
BONES

Suggestions

At the outset, you will want to use comments to yourself throughout your documents; anything written in lieu of, or in addition to, the word "comment" below will not display on your page, but will be in your source for your convenience. Sometimes dashes will confuse some browsers, so avoid special characters in your comments.
 
<!-- comment -->





Color Chart

You can just double click on any color box to select the hexcode and plug it into a document -
remembering to add the leading # sign.

000000 000033 000066 000099 0000CC 0000FF
003300 003333 003366 003399 0033CC 0033FF
006600 006633 006666 006699 0066CC 0066FF
009900 009933 009966 009999 0099CC 0099FF
00CC00 00CC33 00CC66 00CC99 00CCCC 00CCFF
00FF00 00FF33 00FF66 00FF99 00FFCC 00FFFF
330000 330033 330066 330099 3300CC 3300FF
333300 333333 333366 333399 3333CC 3333FF
336600 336633 336666 336699 3366CC 3366FF
339900 339933 339966 339999 3399CC 3399FF
33CC00 33CC33 33CC66 33CC99 33CCCC 33CCFF
33FF00 33FF33 33FF66 33FF99 33FFCC 33FFFF
660000 660033 660066 660099 6600CC 6600FF
663300 663333 663366 663399 6633CC 6633FF
666600 666633 666666 666699 6666CC 6666FF
669900 669933 669966 669999 6699CC 6699FF
66CC00 66CC33 66CC66 66CC99 66CCCC 66CCFF
66FF00 66FF33 66FF66 66FF99 66FFCC 66FFFF
990000 990033 990066 990099 9900CC 9900FF
993300 993333 993366 993399 9933CC 9933FF
996600 996633 996666 996699 9966CC 9966FF
999900 999933 999966 999999 9999CC 9999FF
99CC00 99CC33 99CC66 99CC99 99CCCC 99CCFF
99FF00 99FF33 99FF66 99FF99 99FFCC 99FFFF
CC0000 CC0033 CC0066 CC0099 CC00CC CC00FF
CC3300 CC3333 CC3366 CC3399 CC33CC CC33FF
CC6600 CC6633 CC6666 CC6699 CC66CC CC66FF
CC9900 CC9933 CC9966 CC9999 CC99CC CC99FF
CCCC00 CCCC33 CCCC66 CCCC99 CCCCCC CCCCFF
CCFF00 CCFF33 CCFF66 CCFF99 CCFFCC CCFFFF
FF0000 FF0033 FF0066 FF0099 FF00CC FF00FF
FF3300 FF3333 FF3366 FF3399 FF33CC FF33FF
FF6600 FF6633 FF6666 FF6699 FF66CC FF66FF
FF9900 FF9933 FF9966 FF9999 FF99CC FF99FF
FFCC00 FFCC33 FFCC66 FFCC99 FFCCCC FFCCFF
FFFF00 FFFF33 FFFF66 FFFF99 FFFFCC FFFFFF
MORE COLOR CHOICES
See the Color Named Chart

Coaching program under development by M.C. "Mac" Yarnell at Eaglecliff Incorporated, Wichita, KS
eaglewebs@eaglecliff.net ©2002Eaglemaster Webmaker