HTML - INTRODUCTION -00
This is a primer for producing documents in HTML, the hypertext markup language used on the World WideWeb. This guide is intended to be an introduction to using HTML and creating files for the Web. You shouldalso check your local bookstore; there are many volumes about the Web and HTML that could be useful.This guide is copyright by the Board of Trustees of the University of Illinois. All rights reserved. The guidemay not be reproduced without written permission from the National Center for SupercomputingApplications and it may not be sold.Getting StartedTerms to KnowWhat Isn't CoveredHTML VersionHTML DocumentsWhat an HTML Document IsHTML EditorsGetting Your Files on a ServerTags ExplainedThe Minimal HTML DocumentA Teaching ToolMarkup TagsHTMLHEADTITLEBODYHeadingsParagraphsListsPreformatted TextExtended QuotationsAddressesForced Line Breaks/Postal AddressesHorizontal RulesCharacter FormattingLogical Versus Physical StylesEscape SequencesLinkingRelative Pathnames Versus Absolute PathnamesURLsLinks to Specific SectionsMailtoInline ImagesImage Size AttributesAligning ImagesAlternate Text for ImagesBackground GraphicsBackground ColorExternal Images, Sounds, and AnimationsTablesTable TagsGeneral Table FormatTables for Nontabular InformationFill-out FormsTroubleshootingAvoid Overlapping TagsEmbed Only Anchors and Character TagsDo the Final StepsCommenting Your FilesFor More InformationStyle GuidesOther Introductory DocumentsAdditional Online ReferencesThanks
Getting Started
Terms to Know
WWW World Wide Web
Web World Wide Web
SGML Standard Generalized Markup Language--a standard for describing markup languages
DTD Document Type Definition--this is the formal specification of a markup language, written using SGML
HTML HyperText Markup Language--HTML is an SGML DTDIn practical terms, HTML is a collection of platform-independent styles (indicated by markup tags) thatdefine the various components of a World Wide Web document. HTML was invented by TimBerners-Lee while at CERN, the European Laboratory for Particle Physics in Geneva.
What Isn't CoveredThis primer assumes that you:know how to use NCSA Mosaic or some other Web browserhave a general understanding of how Web servers and client browsers workhave access to a Web server (or that you want to produce HTML documents for personal use inlocal-viewing mode)
HTML VersionThis guide reflects the most current specification--HTML Version 2.0-- plus some additional features that havebeen widely and consistently implemented in browsers. Future versions and new features for HTML are underdevelopment.
HTML Documents
What an HTML Document IsHTML documents are plain-text (also known as ASCII) files that can be created using any text editor (e.g.,Emacs or vi on UNIX machines; BBEdit on a Macintosh; Notepad on a Windows machine). You can also useword-processing software if you remember to save your document as "text only with line breaks."
HTML EditorsSome WYSIWYG editors are available (e.g., HotMetal, which is available for several platforms or AdobePageMill for Macintoshes). You may wish to try one of them after you learn some of the basics of HTMLtagging. It is useful to know enough HTML to code a document before you determine the usefulness of aWYSIWYG editor.If you haven't already selected your software, refer to an online listing of HTML editors (organized byplatform) to help you in your search for appropriate software.
Getting Your Files on a ServerIf you have access to a Web server at school or work, contact your webmaster (the individual who maintainsthe server) to see how you can get your files on the Web. If you do not have access to a server at work orschool, check to see if your community operates a FreeNet, a community-based network that provides freeaccess to the Internet. Lacking a FreeNet, you may need to contact a local Internet provider that will post yourfiles on a server for a fee. (Check your local newspaper for advertisements or with your Chamber ofCommerce for the names of companies.)
Tags ExplainedAn element is a fundamental component of the structure of a text document. Some examples of elements areheads, tables, paragraphs, and lists. Think of it this way: you use HTML tags to mark the elements of a file foryour 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 anglebracket (<), a tag name, and a right angle bracket (>). Tags are usually paired (e.g., <H1> and </H1>) to startand end the tag instruction. The end tag looks just like the start tag except a slash (/) precedes the text withinthe 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 appropriateattribute with the image source HTML code. Tags that have optional attributes are noted below.
NOTE: HTML is not case sensitive. <title> is equivalent to <TITLE> or <TiTlE>. There are a fewexceptions noted in Escape Sequences below.Not all tags are supported by all World Wide Web browsers. If a browser does not support a tag, it (usually)just ignores it.
The Minimal HTML DocumentEvery HTML document should contain certain standard HTML tags. Each document consists of head andbody 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 HTMLand SGML 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. (Somebrowsers will format your HTML file correctly even if these tags are not included. But some browsers won't!So make sure to include them.)Click to see the formatted version of the example. A longer example is also available but you should readthrough the rest of the guide before you take a look. This longer-example file contains tags explained in thenext section.
A Teaching ToolTo see a copy of the file that your browser reads to generate the information in your current window, selectView Source (or the equivalent) from the browser menu. The file contents, with all the HTML tags, aredisplayed in a new window.This is an excellent way to see how HTML is used and to learn tips and constructs. Of course, the HTMLmight not be technically correct. Once you become familiar with HTML and check the many online andhard-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 Webpages or modify the format to suit your purposes.
Markup Tags
HTMLThis element tells your browser that the file contains HTML-coded information. The file extension .html alsoindicates 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.)
HEADThe head element identifies the first part of your HTML-coded document that contains the title. The title isshown as part of your browser's window (see below).
TITLEThe title element contains your document title and identifies its content in a global context. The title is displayedsomewhere on the browser window (usually at the top), but not within the text area. The title is also what isdisplayed on someone's hotlist or bookmark list, so choose something descriptive, unique, and relativelyshort. A title is also used during a WAIS search of a server.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 ismore useful than simply calling the document Installation. Generally you should keep your titles to 64characters or fewer.
BODYThe second--and largest--part of your HTML document is the body, which contains the content of yourdocument (displayed within the text area of your browser window). The tags explained below are used withinthe body of your HTML document.
HeadingsHTML has six levels of headings, numbered 1 through 6, with 1 being the most prominent. Headings aredisplayed in larger and/or bolder fonts than normal body text. The first heading in each document should betagged <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.
ParagraphsUnlike documents in most word processors, carriage returns in HTML files aren't significant. So you don'thave to worry about how long your lines of text are (better to have them fewer than 72 characters longthough). Word wrapping can occur at any point in your source file, and multiple spaces are collapsed into asingle space by your browser.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 startsa new paragraph only when it encounters another <P> tag.
Important: You must indicate paragraphs with <P> elements. A browser ignores any indentations or blanklines in the source text. Without <P> elements, the document becomes one large paragraph. (One exception istext tagged as "preformatted," which is explained below.) For example, the following would produce identicaloutput 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
Getting Started
Terms to Know
WWW World Wide Web
Web World Wide Web
SGML Standard Generalized Markup Language--a standard for describing markup languages
DTD Document Type Definition--this is the formal specification of a markup language, written using SGML
HTML HyperText Markup Language--HTML is an SGML DTDIn practical terms, HTML is a collection of platform-independent styles (indicated by markup tags) thatdefine the various components of a World Wide Web document. HTML was invented by TimBerners-Lee while at CERN, the European Laboratory for Particle Physics in Geneva.
What Isn't CoveredThis primer assumes that you:know how to use NCSA Mosaic or some other Web browserhave a general understanding of how Web servers and client browsers workhave access to a Web server (or that you want to produce HTML documents for personal use inlocal-viewing mode)
HTML VersionThis guide reflects the most current specification--HTML Version 2.0-- plus some additional features that havebeen widely and consistently implemented in browsers. Future versions and new features for HTML are underdevelopment.
HTML Documents
What an HTML Document IsHTML documents are plain-text (also known as ASCII) files that can be created using any text editor (e.g.,Emacs or vi on UNIX machines; BBEdit on a Macintosh; Notepad on a Windows machine). You can also useword-processing software if you remember to save your document as "text only with line breaks."
HTML EditorsSome WYSIWYG editors are available (e.g., HotMetal, which is available for several platforms or AdobePageMill for Macintoshes). You may wish to try one of them after you learn some of the basics of HTMLtagging. It is useful to know enough HTML to code a document before you determine the usefulness of aWYSIWYG editor.If you haven't already selected your software, refer to an online listing of HTML editors (organized byplatform) to help you in your search for appropriate software.
Getting Your Files on a ServerIf you have access to a Web server at school or work, contact your webmaster (the individual who maintainsthe server) to see how you can get your files on the Web. If you do not have access to a server at work orschool, check to see if your community operates a FreeNet, a community-based network that provides freeaccess to the Internet. Lacking a FreeNet, you may need to contact a local Internet provider that will post yourfiles on a server for a fee. (Check your local newspaper for advertisements or with your Chamber ofCommerce for the names of companies.)
Tags ExplainedAn element is a fundamental component of the structure of a text document. Some examples of elements areheads, tables, paragraphs, and lists. Think of it this way: you use HTML tags to mark the elements of a file foryour 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 anglebracket (<), a tag name, and a right angle bracket (>). Tags are usually paired (e.g., <H1> and </H1>) to startand end the tag instruction. The end tag looks just like the start tag except a slash (/) precedes the text withinthe 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 appropriateattribute with the image source HTML code. Tags that have optional attributes are noted below.
NOTE: HTML is not case sensitive. <title> is equivalent to <TITLE> or <TiTlE>. There are a fewexceptions noted in Escape Sequences below.Not all tags are supported by all World Wide Web browsers. If a browser does not support a tag, it (usually)just ignores it.
The Minimal HTML DocumentEvery HTML document should contain certain standard HTML tags. Each document consists of head andbody 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 HTMLand SGML 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. (Somebrowsers will format your HTML file correctly even if these tags are not included. But some browsers won't!So make sure to include them.)Click to see the formatted version of the example. A longer example is also available but you should readthrough the rest of the guide before you take a look. This longer-example file contains tags explained in thenext section.
A Teaching ToolTo see a copy of the file that your browser reads to generate the information in your current window, selectView Source (or the equivalent) from the browser menu. The file contents, with all the HTML tags, aredisplayed in a new window.This is an excellent way to see how HTML is used and to learn tips and constructs. Of course, the HTMLmight not be technically correct. Once you become familiar with HTML and check the many online andhard-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 Webpages or modify the format to suit your purposes.
Markup Tags
HTMLThis element tells your browser that the file contains HTML-coded information. The file extension .html alsoindicates 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.)
HEADThe head element identifies the first part of your HTML-coded document that contains the title. The title isshown as part of your browser's window (see below).
TITLEThe title element contains your document title and identifies its content in a global context. The title is displayedsomewhere on the browser window (usually at the top), but not within the text area. The title is also what isdisplayed on someone's hotlist or bookmark list, so choose something descriptive, unique, and relativelyshort. A title is also used during a WAIS search of a server.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 ismore useful than simply calling the document Installation. Generally you should keep your titles to 64characters or fewer.
BODYThe second--and largest--part of your HTML document is the body, which contains the content of yourdocument (displayed within the text area of your browser window). The tags explained below are used withinthe body of your HTML document.
HeadingsHTML has six levels of headings, numbered 1 through 6, with 1 being the most prominent. Headings aredisplayed in larger and/or bolder fonts than normal body text. The first heading in each document should betagged <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.
ParagraphsUnlike documents in most word processors, carriage returns in HTML files aren't significant. So you don'thave to worry about how long your lines of text are (better to have them fewer than 72 characters longthough). Word wrapping can occur at any point in your source file, and multiple spaces are collapsed into asingle space by your browser.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 startsa new paragraph only when it encounters another <P> tag.
Important: You must indicate paragraphs with <P> elements. A browser ignores any indentations or blanklines in the source text. Without <P> elements, the document becomes one large paragraph. (One exception istext tagged as "preformatted," which is explained below.) For example, the following would produce identicaloutput 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