Allen & Company HTML for Newcomers
Home Index IntroductionLesson 1


Using this Lesson

 
If you've completed the Introduction you know how to use this Lesson. If not, remember:

In the Introduction, you created a plain text file of notes to use in this Lesson. It's better to use your own file, but if you don't have it, download this exampleACTIVE.TXT now.

Remember, you can if you prefer (for details, click here).

Plain Text into HTML

In , we'll mark up our plain text file (ACTIVE.TXT), turning it into . If you're unsure of what means, hover your mouse over for a brief description.

Open the notes we made in Notepad

If you have Notepad's window open from the previous session, you can skip . Otherwise, remember that Notepad won't always be the editor registered to open TXT files, so we'll get some more practice with the method.

Glance through the preview below first, then click the button to go ahead :

This is an InfoBox. We use it to include incidental extra details, or reminders. An InfoBox works like a dynamic footnote you call up with your mouse. The details don't intrude into the main text, but are easily consulted. Your cue to find them is either a or a term in purple text. All these InfoBox notes are built into the page, so they work online or offline. We use a distinctive, bold purple cue where it's more appropriate. Either way, you'll know there are more details you can read whenever you want, simply by hovering your mouse over this device. HTML=HyperText Markup Language is a system of tags to specify text layout. A tag looks like <b>M</b>, which says: put the letter M in bold. A <b> says start making what follows bold, and a </b> says stop. Tags usually come in start/stop pairs. It's how we put bold letters in "HyperText Markup Language". A browser (such as Internet Explorer or Mozilla) doesn't show the tags, it obeys them. An editor like Notepad merely shows the tags along with other text. In some Windows versions (eg Windows Millennium), the Open With option is shown at the first Right-click, so you won't need to use the  Shift +Right-click method that we explain in .
Open With can be used to reset the file association for a particular file (we won't do that now). To reset an association, check the Always use box (Windows normally checks this for you if there is no file association set for the file type).

 Note  Remember to use the Notepad window in its default size.

Restored means a window that's neither maximized nor minimized. Its control buttons look like this . Using Notepad in a restored window means you can see the CueWindow properly. onClick is the term for the JavaScript event that occurs when you click the mouse cursor on an area of screen. JavaScript is an event-driven language. Its functions are often fired by events. When several windows are open, only one has focus (it has a standard dark blue title bar). The window with focus is the one that receives any keystrokes from your keyboard. Where a window has keyboard input boxes, the box with focus is the one that typed characters will appear in. An easy way to shift focus is to click on a window (or its Taskbar button), or click in an input box. You can also use  Alt Tab  to put up a menu that will cycle the focus through all windows.

The box

With the file open in Notepad, we'll make a note about the box. As we learnt in the Introduction, this supplies instant help ing any technical term.

Use the scroll bars in the to see all of a large preview – remember to return to the Notepad window so you can type into it :

Text into HTML

Since an file is a plain text file with an .HTM or .HTML extension, the next step is to save our plain text notes as active.htm :

 Note  file names are often in lowercase, because this is common in , where file names are case-sensitive.

Unix is an operating system devised by Ken Thompson at Bell Laboratories in 1969. It was named UNICS from a pun on MULTICS (MULTIplexed Information and Computing Service), a project he had worked on at Bell. UNICS was later shortened to Unix. Unix and its clones are widely used on the Servers that form the backbone of the Net.

View your file as HTML

To understand tags properly, it helps to see their effect at each step. The below will help you open your file in a browser window scaled to fit the Lesson's screen layout.

Click in the box, enter filename – or browse

Enter full path, or click Browse and locate your file:



Either enter the to the active.htm file in the box; Or use the  Browse  button to find it; then click on it; then click the  Open  button (you can use the Files of type pull-down box to look only for *.htm,*.html files to make it easier to locate).

The full path to a file includes its drive letter and folder name(s), too. For a file on your Desktop this might look like: c:\windows\desktop\active.htm but it will vary with your Windows version and setup. Notice that you need to click in the box first (to set focus) before you can type in it. If you prefer, use the  Browse  button to find active.htm with an Explorer control.

Your notes as HTML

With the path to your file in the box, click the  View as HTML  button. A new window opens, placed so you can compare your progress at each  Step  with a .

Some work remains!

When a browser renders your initial active.htm it's displayed with:

To improve that, we need to mark up the file. As we said, some work remains!

Art is long, life is short

Marking up text is an art. But, sometimes, all you want is a legible result, fast. So, first, let's learn one quick kludge – the tag :

You must save changes

You did remember to click File, Save to save that change to active.htm, didn't you?

The tag

Let's stop calling the new window: "new window", and give it a title that appears on its Taskbar button. This is done with the tag :

When you've saved the change, click the Taskbar button for the new window, and press  F5  to refresh it. Its Taskbar button (and Title bar) will show the name  HTML view , which makes it easier to distinguish amidst the other buttons on your Taskbar.

Remember to get help

Use the help built into this page (it's there whether you stay online or ):

 Note  There's no need to learn these details as soon as you meet a new term. Let the Lesson guide you through the initial steps. Then only when you need to remind yourself, or want to learn more – the boxes show additional syntax examples not covered in the main Lesson.

Correct spelling is vital when using tags

You must spell tag names correctly. Browsers don't spellcheck. They ignore tags they don't recognise. If you spell a tag wrongly, say <tilte> for , or forget the  /  in a closing tag, it won't be obeyed (and like all tags it won't be displayed either).

A Browser treats anything you put between < and > symbols as a potential tag. As we'll see in Lesson 2, a lot more than just the tag name can go inside these symbols. Browsers obey what they recognise, but ignore what they can't. So you're ignored if your spelling is bad! This ensures that when new tags are introduced, old Browsers will ignore them (instead of giving an error).

The Lesson plan:
Marking up properly

 
That was the quick fix ... now to do it properly. We'll split the job into four stages, and learn a useful range of mark up techniques on the way. The is the main outline plan:

Using HTML tags:
  1. Define main structure of the document
  2. Centred text, Paragraphs, and Line Breaks
  3. Create Definition lists
  4. Create Ordered and Unordered lists

There's a  Step  button to check the  HTML view  of your document after every tiny change. By working in small steps, and checking each one, you learn more easily.

When you mark up a file (that is, add tags and rules that tell a browser how to display it), the result is usually called an HTML "document", rather than a "file".

Back to square one

We need to take out the tags again. Their correct use is for short extracts of text where an exact format is needed, such as Computer Program Code examples.

With the tags out, we'll be able see the effect of other tags properly :

The structural tags:
Browsers can infer the document structure

 
It's conventional to use structural tags to divide the whole document explicitly into two sections. Most browsers can deduce the structure (at least in simple cases), and these tags won't make any difference to the way we see our current document in  HTML view :

  1. Define main structure of the document
    • the <html> tag encloses the whole document
    • the <head> tag defines the Head section
    • the <body> tag defines the Body section

The tag

First, and tags are placed around the entire document :

The and tags

A document is usually laid out in two principal, explicit sections:

– contained between and tags
Used for items that define or manage the overall document. These are items (such as the document title) that don't normally appear as part of the main content.
 
– contained between and tags
For the document content that's to be shown in the browser window.
Add these tags in Notepad. Make the document title a part of the :

The document Body is where the main content of the page goes. In simple pages, it may be just paragraphs of text. In more complex cases there will be text, images, tables, and a variety of other content. The Body is contained between <body> and </body> tags. The Head is where the properties of a document, such as Title, Keywords (for search engines), Style details, Script functions, and many other administrative elements go. Most of these are not seen by the user. The Head is contained between <head> and </head> tags.

Uppercase/lowercase?

By the way, it doesn't matter whether you use uppercase or lowercase for tag names. But do stick to one convention or the other. If you mix cases, you may find Browsers won't render your documents properly, as newer and tighter standards are introduced.

Basic layout:
Centring, paragraphing, and line control

 
As we'll see in Lesson 2, there is often an tag and an alternative Style Rule that achieves the same effect. That's because Style Rules are designed to supersede older ways of doing things (especially for fine details of layout).

But remains a simpler way to handle basic layout, and that's what we'll start with:

  1. Centred text, Paragraphs, and Line Breaks
    • the <center> tag
    • the <p> (paragraph) tag
    • the <br> (line break) tag

The tag

This does what it says, (but you must spell it US-style=center). We can use it to centre the heading of the notes :

The (paragraph) tag

We'll put the first definition in a paragraph, with the tag. This simple tag is very useful for basic text layout. As usual, there's a corresponding close tag: .

Add the paragraph tags around the definition :

You may read that </p> is not needed. However, if you don't close a paragraph, then: (a) the height of its final line will be wrong if it's not using the default font and size; (b) any following float-left text (such as the side headings on this page) may not align properly with the main text. So always close your paragraphs with </p>.

The (line break) tag

The line break tag is unusual: it doesn't have a closing form. It's an instruction to the Browser to start a new line. It's like pressing  Return  when you're typing a text file.

Browsers wrap your text automatically

A Browser doesn't treat a  Return  as a cue to start a new line. One or more  Return s (like multiple  Space s) are rendered as a single  Space . The resulting text is wrapped automatically to fit the Browser window. The Browser chooses a convenient point to wrap a line, such as between words, or at a  –  (dash or hyphen).

Use a line break tag to start a new line :

Definition lists:
Tags intended for terms and their definitions

 
We've marked up and its definition with paragraph and line break tags. These are useful tags to know, but for the other definitions we'll try something different.

has several handy groups of tags to format lists. There's a special group meant for lists of terms and their associated definitions:

  1. Create Definition lists
    • one <dl> tag pair encloses whole Definition List
    • a <dt> tag pair encloses each defined Term
    • a <dd> tag pair encloses each term's Definition

A definition list uses three (related) tags

We'll practise on and its definition first (and extend the tagging to other terms afterwards). There are three two-letter tags. Each starts with a letter d for Definition. The second letter is either l, t, or d (l=List, t=Term, d=its Definition). They work like this:

whole List (possibly many lines of text)
One pair (open/close) of these tags enclose the whole List, including all terms (each with their special tags), and all definitions (each with their special tags)

 
each Term to be defined
Within the list, a pair (open/close) of these tags enclose each Term

 
the Definition of the term
Within the list, a pair (open/close) of these tags enclose each Definition
In the preview, we show the three pairs of tags colour-coded to make it easier to see how they match up. In Notepad, tag the definition with them :

 Note  You're free to insert blank lines and white space (= Space  or  Tab  characters). The browser ignores them, but they make the document easier for you to read.

An HTML document is like source code that your browser interprets (much as, say, computer program source code in BASIC is, when the program runs). As with program source code, it helps you to read your source document if you lay it out clearly.

Extending the list to include Lookup box

Let's extend the Definition List tagging to include the term LookUp box and its definition, too. We can do it like this:

  1. Leave the (open) list tag in place
  2. Move the (close) tag so it comes after the definition
  3. Tag the term LookUp box with and,
  4. Tag its definition with and, as we did before
Make these changes in Notepad now :

Extending the list to include What is active text?

In the same way, we can extend the Definition List tagging back, so that it includes the question and its answer.

This time we leave the (close) tag in place, but move the (open) tag. We also need to take out the paragraph and line-break tags and replace them with the Definition List tags for a term and its definition :

Extending the list to include CueWindow

Now extend the Definition List tagging to include the final term, . We can also improve its definition with a new type of list (but we'll defer that until Stage 4).

For now, tag , and its entire definition, as we did for the other terms. Don't forget to move the (close) tag, too :

Other list styles:
Ordered and Unordered

 
There are two other list styles for which provides dedicated tags:

  1. Create Ordered and Unordered lists
    Ordered lists:
    • the <ol> tag encloses the whole Ordered List
    • the <li> tag encloses each List item
    Unordered lists:
    • the <ul> tag encloses the whole Uordered List
    • the same <li> tag encloses each List item
    Adding White Space
    • using <br> tags to add blank lines
    • the &nbsp; (=Non-Breaking Space) symbol

Ordered Lists:
Each item is numbered automatically

 
In our definition, we have two Styles: Edit and MultiStep. We can make them stand out better by tagging them as a list. Lists can be nested, so we can create this new list inside the main Definition List.

We'll use and tags for the two Styles, to create an Ordered List. The preview has the tags colour-coded to show how they match up :

Adding extra text to the list items

With the items tagged as a list, we can add further text to each of them. For example, we can include a gloss (explanation) for each. Try it for yourself :

Adding an extra item

If we add more items, the browser will number them for us. For example, there's another style of , which is used in our Batch File Course.

It simulates a DOS window, and it looks like this :

MS-DOS (=the MicroSoft Disk Operating System) included Batch processing from version 1.0 (August 1981). It was added to help IBM engineers run long lists of commands to test MS-DOS on the IBM Personal Computer original prototype.
The Batch language developed steadily through later versions of MS-DOS, and is always installed as part of Windows (but many users aren't aware of this). Our full-scale Course will teach newcomers how to use the Batch Language (on a Windows 95/98/ME PC). Details: Allenware.com home page.

Add DOS style to the existing list

Add the new style, DOS and its description. Make it first in the list and the browser will automatically re-number the other two items :

Unordered lists:
List items are displayed as bullet points

 
For items that you want to display as a series of bullet points, rather than a numbered sequence, you can use the and tags to create an Unordered List.

Indeed, the three styles would be more effectively presented in this way.

So let's change our Ordered List to an Unordered one :

Adding white space:
Using the tag to add blank lines

 
We can improve the look of the Definition List with a blank line between each pair of Term+Definition. Put a tag in front of each Term except the first :

Non-breaking Spaces:
Adding white space and controlling line wrap

 
We've seen that multiple  Space s are ignored by the Browser. We've also seen that the Browser will wrap lines at any boundary between words.

Sometimes you need to insert several consecutive  Space s, or avoid a line break ever coming between two adjacent words. For this, you can use a Non-breaking Space.

This is one of a number of special s inserted with the  & mnemonic ;  syntax. The mnemonic for a non-breaking space is nbsp, so the symbol for it is: &;

The Browser will render each &; as a  Space . For example, if we want to indent the Copyright  message by four  Space s, we use &; four times :

Controlling line wrap

A Browser will wrap lines at any convenient  Space  or  hyphen  (and at a few other points). It's a matter of chance (depending on window size and screen resolution). But you can use non-breaking spaces to control line wrap, in a subtle way.

For example, suppose you're writing the History of a War. See how a strong, clear sentence can become a weak, confused one with an unlucky line wrap.

They claimed it was a just War. It was not.
In this essay I will explain why.
They claimed it was a just War. It was
not. In this essay I will explain why.

If you write: It was&nbsp;not. your sentence will never wrap between was not ... On that nice point of rhetoric, we'll close this Lesson.

pull-down box

You can refresh your memory for any point you're unsure about with this pull-down version of the Course Reference. It has s for all the terms we've met so far.

The Lesson summary

Remember the cycle: PreviewDoReview. It's time to Review what we've learnt:

If you're taking the next Lesson now, keep Notepad and  HTML view  windows open.

The next Lesson

The Index has the syllabus for the next Lesson, where we'll add style to our document with Cascading Style Sheet rules. See you then.

William Allen and Linda Allen
© Copyright 2003- Allen & Company. All rights reserved ©