HTML First Tutorial

Contents

Basic Terms
What an HTML document is…
HTML Editors
Getting Your Files on a Server
Tags Explained
The Minimal HTML Document
A Teaching Tool
Markup Tags
Special Characters

 

Basic Terms...

WWWWorld Wide Web
Web World Wide Web
HTML HyperText Markup Language--In practical terms, HTML is a collection of platform-independent styles (indicated by markup tags) that define the various components of a World Wide Web document. HTML was invented by Tim Berners-Lee while at CERN, the European Laboratory for Particle Physics in Geneva.
Browser The software program which allows someone to access websites on the WWW. Examples- Netscape, Firefox, Opera, Internet Explorer, Safari, etc.
Web Host The web server that can store and allow access to the webpage(s) that you could create.
FTP Software used to send webpages to a server or receive webpages from a server.
Tags The formatting commands that are used throughout webpages that allow a browser to understnad how to display the page on the user's screen. Example: <P>Test</P>
Upload Transfering files from your "client" machine to a server machine.
Client The term used to refer to the "typical internet users". Clients use the internet by accessing the resources of other computers connected to the web.
Server A machine that exist on the internet that has special software which allows client computers to access its webpages.

What an HTML document is…
HTML documents are plain-text files that can be created using any text editor – however Notepad on Windows machines and SimpleText on a Macintosh machines will work nicely. Note: The resulting file must be saved using the file extension HTM or HTML.

Extra Info: The webpage you see on the internet come in a variety of flavors, however most of the pages are still just plain ol’ HTML pages. The other kinds are PHP, ASP, XML, Perl, and so forth. Sometimes you can tell what type of web page it is by looking at the files extension in the browser window. For example - a file with extension “php” is what kind of file? That's right it is a PHP file. Back to HTML stuff…

HTML Editors
Some WYSIWYG editors are also available (e.g., Macromedia Dreamweaver, Microsoft Frontpage, and so forth). WYSIWYG is an acronym for "what you see is what you get"; it means that you design your HTML document visually, as if you were using a word processor, instead of writing the markup tags in a plain-text file and imagining what the resulting page will look like. It is useful to know enough HTML to code a document before you determine the usefulness of a WYSIWYG editor, in case you want to add HTML features that your editor doesn't support. Also, some WYSIWYG editors force additional HTML code into your file or they sometimes don’t produce what you may expect – therefore it is crucial that you first learn HTML coding.

Getting Your Files on a Server
If you have access to a Web server at school or work, contact your webmaster (the individual who maintains the server) to see how you can get your files on the Web. If you do not have access to a server at work or school, check to see if your community operates a FreeNet, a community-based network that provides free access to the Internet. Lacking a FreeNet, you may need to contact a local Internet provider that will post your files on a server for a fee. Check the internet using the search string "website hosting." There will be plenty of possibilities so search well for the best deal.

When you have an account with a website hosting company then you will be issued a URL and password so that you can "upload" your files to their server.

Tags Explained
An element is a fundamental component of the structure of a text document. Some examples of elements are heads, tables, paragraphs, and lists. Think of it this way: you use HTML tags to mark the elements of a file for your browser. Elements can contain plain text, other elements, or both.

To denote the various elements in an HTML document, you use tags. HTML tags consist of a left angle bracket (<), a tag name, and a right angle bracket (>). Tags are usually paired (e.g., <H1> and </H1>) to start and end the tag instruction. The end tag looks just like the start tag except a slash (/) precedes the text within the brackets. HTML tags are listed below.

Some elements may include an attribute, which is additional information that is included inside the start tag. For example, you can specify the alignment of images (top, middle, or bottom) by including the appropriate attribute with the image source HTML code. Look carefully at the syntax (rules for creating) for the tags to see which have optional attributes.

There are two basic types of elements - container elements and empty elements. A container element has a starting tag and a ending tag. An example of this element is the paragraph element: <P>...<\P>. There can be a combination of text and other tags within this element.

Empty element is the other type of HTML element - it contains nothing in the middle because there is no middle. For example: <BR> is an empty element. This element simply tells the browser to continue displaying the HTML page on the next line.

NOTE: HTML is not case sensitive. <title> is equivalent to <TITLE> or <TiTlE>. There are a few exceptions noted in Escape Sequences below. Also, be careful not to overlap the elements - you can include an element within another element by nesting. For example: <HEAD><TITLE></HEAD></TITLE> is wrong, but <HEAD><TITLE></TITLE></HEAD> is correct because title is nested within the head element.

Not all tags are supported by all World Wide Web browsers. If a browser does not support a tag, it will simply ignore it. Any text placed between a pair of unknown tags will still be displayed, however.

The Minimal HTML Document
Every HTML document should contain certain standard HTML tags. Each document consists of head and body text. The head contains the title, and the body contains the actual text that is made up of paragraphs, lists, and other elements. Browsers expect specific information because they are programmed according to HTML specifications.

Required elements are shown in this sample bare-bones document:
<html>
<head>
<TITLE>A Simple HTML Example</TITLE>
</head>
<body>
<H1>HTML is Easy To Learn</H1>
<P>Welcome to the world of HTML.
This is the first paragraph. While short it is
still a paragraph!</P>
<P>And this is the second paragraph.</P>
</body>
</html>

The required elements are the <html>, <head>, <title>, and <body> tags (and their corresponding end tags). Because you should include these tags in each file, you might want to create a template file with them. (Some browsers will format your HTML file correctly even if these tags are not included. But some browsers won't! So make sure to include them.)

Task: Using Notepad - place the simple code above into a file, save it, and then display the resulting webpage.

Is there anything odd or unexpected about the webpage you created?

A Teaching Tool
To see a copy of the file that your browser reads to generate the information in your current window, select View Source (or the equivalent) from the browser menu. (Most browsers have a "View" menu under which this command is listed.) The file contents, with all the HTML tags, are displayed in a new window.

This is an excellent way to see how HTML is used and to learn tips and constructs. Of course, the HTML might not be technically correct. Once you become familiar with HTML and check the many online and hard-copy references on the subject, you will learn to distinguish between "good" and "bad" HTML.

Remember that you can save a source file with the HTML codes and use it as a template for one of your Web pages or modify the format to suit your purposes.

Markup Tags

Task: Using Notepad - Use the file you created above and add additional HTML tags to it. Try each of the tags. Experiment and see why certain things happen they way they do. Try various attributes to go along with your tags. For example...make sure you place bgcolor attribute in the body of the webage. Try all the different heading statements below.

HTML
This element tells your browser that the file contains HTML-coded information. The file extension .html also indicates this an HTML document and must be used. (If you are restricted to 8.3 filenames (e.g., LeeHome.htm, use only .htm for your extension.)

HEAD
The head element identifies the first part of your HTML-coded document that contains the title. The title is shown as part of your browser's window (see below).

TITLE
The title element contains your document title and identifies its content in a global context. The title is typically displayed in the title bar at the top of the browser window, but not inside the window itself. The title is also what is displayed on someone's hotlist or bookmark list, so choose something descriptive, unique, and relatively short. A title is also used to identify your page for search engines (such as HotBot or Infoseek).

For example, you might include a shortened title of a book along with the chapter contents: NCSA Mosaic Guide (Windows): Installation. This tells the software name, the platform, and the chapter contents, which is more useful than simply calling the document Installation. Generally you should keep your titles to 64 characters or fewer.

BODY
The second--and largest--part of your HTML document is the body, which contains the content of your document (displayed within the text area of your browser window). The tags explained below are used within the body of your HTML document.

Headings
HTML has six levels of headings, numbered 1 through 6, with 1 being the largest. Headings are typically displayed in larger and/or bolder fonts than normal body text. The first heading in each document should be tagged <H1>.

The syntax of the heading element is:
<Hy>Text of heading </Hy>
where y is a number between 1 and 6 specifying the level of the heading.

Do not skip levels of headings in your document. For example, don't start with a level-one heading (<H1>) and then next use a level-three (<H3>) heading.

Paragraphs
Unlike documents in most word processors, carriage returns in HTML files aren't significant. In fact, any amount of whitespace -- including spaces, linefeeds, and carriage returns -- are automatically compressed into a single space when your HTML document is displayed in a browser. So you don't have to worry about how long your lines of text are. Word wrapping can occur at any point in your source file without affecting how the page will be displayed.

In the bare-bones example shown in the Minimal HTML Document section, the first paragraph is coded as

<P>Welcome to the world of HTML.
This is the first paragraph.
While short it is
still a paragraph!</P>

In the source file there is a line break between the sentences. A Web browser ignores this line break and starts a new paragraph only when it encounters another <P> tag.

Important: You must indicate paragraphs with <P> elements. A browser ignores any indentations or blank lines in the source text. Without <P> elements, the document becomes one large paragraph. (One exception is text tagged as "preformatted," which is explained below.) For example, the following would produce identical output as the first bare-bones HTML example:

<H1>Level-one heading</H1>
<P>Welcome to the world of HTML. This is the
first paragraph. While short it is still a
paragraph! </P> <P>And this is the second paragraph.</P>

To preserve readability in HTML files, put headings on separate lines, use a blank line or two where it helps identify the start of a new section, and separate paragraphs with blank lines (in addition to the <P> tags). These extra spaces will help you when you edit your files (but your browser will ignore the extra spaces because it has its own set of rules on spacing that do not depend on the spaces you put in your source file).

Note: The </P> closing tag may be omitted. This is because browsers understand that when they encounter a <P> tag, it means that the previous paragraph has ended. However, since HTML now allows certain attributes to be assigned to the <P> tag, it's generally a good idea to include it.

Using the <P> and </P> as a paragraph container means that you can center a paragraph by including the ALIGN=alignment attribute in your source file.

<P ALIGN="CENTER">
This is a centered paragraph.

[See the formatted version below.]
</P>

This is a centered paragraph.

It is also possible to align a paragraph to the right instead, by including the ALIGN="RIGHT" attribute. ALIGN="LEFT" is the default alignment; if no ALIGN attribute is included, the paragraph will be left-aligned.

Forced Line Breaks
The <BR> tag forces a line break with no extra (white) space between lines. Using <P> elements for short lines of text such as postal addresses results in unwanted additional white space. For example, with
:

National Center for Supercomputing Applications<BR>
605 East Springfield Avenue<BR>
Champaign, Illinois 61820-5518<BR>

The output is:

National Center for Supercomputing Applications
605 East Springfield Avenue
Champaign, Illinois 61820-5518

Horizontal Rules
The <HR> tag produces a horizontal line the width of the browser window. A horizontal rule is useful to separate major sections of your document.

You can vary a rule's size (thickness) and width (the percentage of the window covered by the rule). Experiment with the settings until you are satisfied with the presentation. For example:

<HR SIZE=4 WIDTH="50%">

displays as:


Special Characters

In some cases, you may want to add special characters to your page...special characters are characters which can not be put into a webpage without using a special code - for example: How do you put additional spaces within you text? Remember th browser will squeeze out all extra spaces until there is only one left...which means if you just put blank spaces in your HTML coded line - the result will always be only one extra space. So how do you get multiple extra blank spaces. Like this: add the special character &nbsp; (non-breaking space). Complete List of Special Characters

Example:

This statement requires lots of blank spaces              in the middle of it.

This HTML code creates the above results:

<p>This statement requires lots of blank spaces&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in
the middle of it.</p>

Task: Using Notepad - Try an assortment of the special characters in your webpage.