HTML Module 1 - Introduction To HTML Training Manual: C C T G L O B A L - C O M
HTML Module 1 - Introduction To HTML Training Manual: C C T G L O B A L - C O M
C C T G L O B A L .C O M
© 1995-2002 Cheltenham Computer Training
Crescent House
© Cheltenham Computer Training 1995-2002 No part of this document may be copied without written permission from
Cheltenham Computer Training unless produced under the terms of a courseware site license agreement with
Cheltenham Computer Training.
All reasonable precautions have been taken in the preparation of this document, including both technical and non-
technical proofing. Cheltenham Computer Training and all staff assume no responsibility for any errors or omissions . No
warranties are made, expressed or implied with regard to these notes . Cheltenham Computer Training shall not be
responsible for any direct, incidental or consequential damages arising from the use of any material contained in this
document. If you find any errors in these training modules, please inform Cheltenham Computer Training. Whilst every
effort is made to eradicate typing or technical mistakes, we apologize for any errors you may detect. All courses are
updated on a regular basis, so your feedback is both valued by us and will help us to maintain the highest possible
standards.
Introduction to HTML
When you • Work with HTML
have • Work with HTML versions
completed • Use Elements and Tags
this learning • Nest Elements
module you • Read a Basic HTML Document
will have • Read a XHTML 1.0 Document
seen how to: • Work with HTML Editors
• Work with WYSIWYG Editors
• Work with Tag-based Editors
Working with • HyperText Markup Language (HTML) is the most common language
HTML used in creating Web documents. HTML is a Standard Generalized
Markup Language (SGML) Document Type Definition (DTD).
• HTML is derived from SGML. SGML is a special language that was
created to standardize document formatting, allow the sharing of
documents over the Internet.
• You can use HTML to create cross-platform Web documents that
contain formatting, links, images, and multimedia components.
• HTML files are plain text documents that have the .htm or .html file
extension.
• Although you can use simple text editors to view and edit the HTML
source code, you will need a web browser to view the formatted
document with images, links, etc.
Working with • The HTML presented in this manual will use the XHTML 1.0
HTML Transitional specification, which is the latest specification from the
Versions World Wide Web Consortium.
HTML Syntax
Nesting • Elements can be nested to provide you with the effect you want. In
Elements the following example, we have nested the bold <strong> element
within the paragraph <p> element. The bold effect will be applied to
the contents between the opening and closing tags:
Note: To nest an element correctly, you should make sure that the
inner element is closed before the outer element is closed. It is
incorrect to straddle elements as shown in the following:
Reading a • An HTML document is divided into the head and the body elements.
Basic HTML The head element contains the title element. The body element
Document contains the content of your HTML page.
• A basic HTML document consists of the following elements:
<html> - The HTML tags define the beginning and ending of an HTML
document.
<head> - The head tags define the beginning and ending of the head
section of the HTML document.
<title> - The title tags nested inside the head tags and defines the
page title of the HTML document.
<body> - The body tags define the beginning and ending of the body
section of the HTML document.
HTML Editors
HTML Editors
Working with • Although you can use a plain text editor such as Notepad to write and
HTML Editors edit your HTML documents, you may want to consider using an HTML
editor to simplify your task.
• There are two categories of editors: WYSIWYG and Tag-based. With
WYSIWYG editors, you can work with the layout of the page instead of
the HTML source code as you would with Tag-based editors.
• Since WYSIWYG editors will generate the HTML source code for you,
they may introduce code that can create problems in your HTML
document. However, the popular editors do allow you to edit the
HTML source code directly.
• Examples of WYSIWYG editors include: Adobe GoLive, Adobe
PageMill, Macromedia DreamWeaver, Microsoft FrontPage, and
NetObjects Fusion.
Working with • One of the main goals of Tag-based editors is to help you write and
Tag-based edit HTML source code. With Tag-based editors, you work with the
Editors HTML source code. Unlike plain text editors, Tag-based editors will
color code your HTML, providing better readability.
• To use these editors, you need to know how to lay out a page with
HTML, and to understand HTML code:
• Tag-based editors have tools to help you enter tags quickly. For
example, commonly used tags have icons that you can click to add
them. With more complex tags, wizards or dialog boxes are provided
to help you add the tag with the attributes you want:
Review Questions
Review Questions
• To create web pages for your web site, you need to create
HTML files. Web browsers process HTML files to display
the formatted document with the appropriate images,
multimedia elements, and links. This file format uses the
extension .htm or .html.
• When you write your HTML document, you will be
referencing images, links, and other elements using URLs.
In most cases, you should use relative URLs to make your
web site more portable, allowing you to move your web site
without breaking the links.
Working with • To create web pages for your web site, you need to create HTML files.
HTML Files Web browsers process HTML files to display the formatted document
with the appropriate images, multimedia elements, and links. This file
format uses the extension .htm or .html.
Working with • You can add JPEG or GIF image files to your web page using the IMG
Image Files element in your HTML document. JPEG image files use the .jpg or
.jpeg file extension. GIF image files use the .gif file extension.
Working with • A wide range of multimedia files can be added to your web pages
Multimedia using the appropriate elements in your HTML document. These files
Files will be covered in the HTML Intermediate courseware.
Naming Files • You HTML files will eventually reside on a web server, allowing your
users to access the pages through the Internet. Although each web
server platform have slightly different naming conventions for files, you
can follow some basic rules that would work with most web server
platforms:
Use a consistent approach when using mixed case names since your
web server may require case-sensitive file names.
Working with • Uniform Resource Locators (URLs) are web addresses that point to
URLs web pages, images, movies, or any file accessible on the Internet. For
example, you can access a web page by entering the URL of the web
page in your browser window:
Protocol: defines the protocol used in opening the requested file. For
example, http://.
Server Name: identifies the server where the requested file is located.
In most cases, domains will only have one server, in which case, the
server name would usually be www.
File Name: identifies the name of the requested file. For example,
index.
File Extension: identifies the file extension of the requested file. For
example, html.
Working with • When you write your HTML document, you will be referencing images,
File Structure links, and other elements using URLs. In most cases, you should use
relative URLs to make your web site more portable, allowing you to
move your web site without breaking the links.
• Relative URLs are URLs defined based on the URL of the current file.
If the file you want to reference is located in the same directory as your
HTML document, then the relative URL is simply the file name and file
extension of the file you want. For example, if you are working on the
index.html page and you want to link to feedback.html, then the
relative URL is "feedback.html":
If the file you want to reference is not located in the same directory as
your HTML document, then you can use ../ to go up one directory level
in the relative URL. Go up as many directory levels as you need so
that you are in the same directory level as the directory that contains
the file you want. You may need to include directory names if the file
you want is located within subdirectories. For example, if you are
working on the canyon.html page in the adventures folder and you
want to link to the canyon.gif file in the media folder, then the relative
URL is "../media/canyon.gif":
• You can simplify the use of relative URLs by creating file structures
that do not contain too many levels of subdirectories.
Understanding Colors
Understanding Colors
000000
Red Blue
Green
Using Web- • For cross-platform compatibility, you may want to use Web-safe colors.
safe Colors This is a set of 216 colors that are common to the PC and Mac system
palette.
• These colors are good for backgrounds, text, links, and logos with flat
color. The colors are also referred to as non-dithering since they are
displayed as smooth, solid colors.
• You can create these colors by using any combination of the hex values
00, 33, 66, 99, CC, and FF for each of the red, green, and blue values.
• Web graphics programs, such as Adobe ImageReady and Macromedia
Flash, will come with the web-safe color palette. The following shows
the ImageReady Color Picker with Only Web Colors selected:
Using Word • Instead of using hex colors, you can use word colors. There are 140
Colors colors that have words assigned. The following is a list of the words
and their hex numbers:
Review Questions
Review Questions
HTML Documents
When you • Use Notepad
have • Write a new HTML Document
completed • Add a Page Title
this learning • Save the HTML Document
module you • Use Meta Data
will have • Identify the Author
seen how to: • Add Key Words
• Add a Description
• Set the Background Color
• Set the Text Colors
• Set the Base URL
• Open an HTML Document in Notepad
• Open an HTML Document from Windows Explorer
• Close an opened HTML Document
• View an HTML Document in a Web Browser
Using • In this manual we will use Notepad as our HTML editor. Once you
Notepad have learned to create HTML documents using a plain text editor, you
will find that it is relatively easy to understand and learn to use the
other editors.
• From the Windows taskbar, click on the Start button, and choose
Programs > Accessories > Notepad. This will create a new Untitled
text document:
Note: You can save this basic HTML document as a sample to save
re-typing this information every time you want to create a new HTML
document.
Adding a • It is a good idea to give each page a title. The page title should be
Page Title descriptive of the page’s content. This title will appear in the title bar
of the web browser:
• Place the insertion point between the opening and closing title tags.
• Type in the page title you want. In the following example, the page
title is Welcome:
Saving the • The document we just wrote is in the text file format. To create the
HTML HTML document, you need to save it with the .htm or .html file
Document extension. Once it is saved with an HTML extension, the web browsers
will recognize the text file as an HTML document, and will process the
code to display the web page.
• From Notepad, choose File > Save As to display the Save As dialog
box:
• From the Save as type dropdown list, select All Files (*.*).
• Enter a name with the .htm or .html file extension in the File name text
box.
• Click Save.
Opening an • From Notepad, choose File > Open to display the Open dialog box:
HTML
Document in
Notepad
• Click on the Files of type down arrow, and select All Files (*.*).
• Locate and select the HTML document you want.
• Click Open.
• Choose Open with from the popup menu to display the Open With
dialog box:
Viewing an • To see how your HTML document is displayed as a web page, open
HTML the document in a web browser.
Document in
a Web To open from Microsoft Internet Explorer:
Browser • From Internet Explorer, choose File > Open to display the Open
dialog box:
• Click on the Choose File button to display the Open dialog box.
• Locate and select the file you want, and click Open.
• Click Open.
Review Questions
Review Questions
Text
When you • Work with Paragraphs
have • Import Text by Copying and Pasting
completed • Type more than one Space
this learning • Create a Line Break
module you • Enter Special Characters
will have • Use Character Map to enter Special Characters
seen how to: • Delete Text
• Use the Font Element
• Use Physical Character Styles
• Use Logical Character Styles
• Use the Heading Elements
• Align Headings
• Align Paragraphs
• Insert a Horizontal Rule
• Indent Quotations
• Use the Preformatted Element
• Create a Bulleted List
• Create a Numbered List
• Create a Definition List
• Nest Lists
Working with • You can use Paragraphs to add text to your web page. HTML
Paragraphs paragraphs allow you to create blocks of text that are separated by a
blank line. The Paragraph or p element must be nested within the
body element.
• In the basic HTML document, place the insertion point between the
opening and closing body tags and press the Enter key twice to insert
a new line.
• In the new line, type the following, replacing the sentence Insert text
for the first paragraph with the text of your paragraph.
Typing more • Unlike with word processors or typewriters, regular spaces created
than one with the Spacebar are translated into a single space in the web
Space browser. To type more than one space, you will need to insert a
special HTML character.
• In the HTML document, place the insertion point where you want to
add extra spaces.
• Type in for every space you want to add.
Note: You can also use the preformatted or pre element to add
multiple spaces. This setting is better suited for formatting a block of
text. (You will learn how to use it later in this manual.)
Creating a • As with extra spaces, web browsers do not recognize any line breaks
Line Break created with the Enter key. A line break forces the text that follows to
begin on a new line. To create a line break in your text, you will need
to insert the br element.
• In the HTML document, place the insertion point where you want to
create a line break.
• Type in <br />.
Entering • In HTML, Special Characters begin with the ampersand (&) and end
Special with the semicolon (;).
Characters • To enter a special character, find the HTML code for the character you
want.
• In the HTML document, place the insertion point where you want the
character to be added, and enter the character's HTML code.
• The following is a list of common special characters:
Using • You can use Character Map to look up special characters. Character
Character Map is a program that is included with Microsoft Windows.
Map to enter • From the Windows Taskbar, click on the Start button and choose
Special Programs > Accessories > System Tools > Character Map to start
Characters the application:
• Locate and select the special character you want to insert into your
HTML document. In the following example, we will select the é (small
e with an acute accent) character:
Note: To see the enlarged version of the character, click and hold
down the mouse button.
• In the bottom-right corner of the screen, you will see the Keystroke
entry. We are only interested in the numeric portion of this entry. In
our example, the numeric value is 0233:
• In the HTML document, place the insertion point where you want to
add the special character.
• Type in &#xxxx; to insert the character. Replace the xxxx with the
numeric value from the Character Map. In our example, type in
é
Deleting Text • Select the text you want to delete, and press the DELETE key.
Note: You should be very careful when deleting text since accidental
deletion of HTML code may have adverse effects on your web page.
Formatting Text
Formatting Text
• Unless you specify a font style for your text, the viewer’s web
browser will use the browser defaults. Use the FONT element
to specify the type, size, and color of font you want to use. You
can use Physical and Logical character styles to further format
your text.
• Physical character styles define the actual appearance of the
selected text. The appearances of the physical styles are
consistent across web browsers.
• Logical character styles define the intended
appearance of the selected text. The
appearances of the logical styles may not be
the same across web browsers.
Using the • Unless you specify a font style for your text, the viewer’s web browser
Font Element will use the browser defaults. You can use the font element to specify
the type, size, and color of font you want to use. The FONT element
must be nested within the body element.
• In the HTML document, place the insertion point before the text you
want to affect. For example, to specify a font style for the entire page,
you would place the insertion point after the <body> tag.
<font face=”arial”>
Note: If you specified a font type that is not installed on the viewer’s
computer, the text will be displayed using the default font.
Note: If the first font type in your list is not installed on the viewer’s
computer, the web browser will use the next font type, and so on.
<font size=”-1”>
Note: Font sizes are set relative to the base font value of the viewer’s
web browser. For example, with the default base font value of 3, you
can decrease the relative font size to –2, and increase the relative font
size to +4.
<font color=”navy”>
• If you are specifying all three FONT attributes at the same time, you
can put them all in one <font> tag. For example, you can use the
following HTML code:
• The Bold text style is specified using the <strong> element. To bold
a selection of text, insert the <strong> tag at the beginning of the
selection and the </strong> tag at the end of the selection:
• The Italic text style is specified using the <em> element. To italicize a
selection of text, insert the <em> tag at the beginning of the selection
and the </em> tag at the end of the selection:
• The following HTML document uses all five physical character styles:
Using Logical • Logical character styles define the intended appearance of the
Character selected text (vs . physical character styles which define the actual
Styles appearance of the selected text). The appearances of the logical
styles may not be the same across web browsers.
• There are seven logical styles: Citation, Code, Emphasis, Keyboard,
Sample, Strong, and Variable.
• The Citation text style marks a cited work, and is usually displayed
with italics. You can specify the Citation text style using the cite
element. To apply the style to a selection of text, insert the <cite> tag
at the beginning of the selection and the </cite> tag at the end of the
selection:
• The Code text style identifies text as computer code, and is usually
displayed with a mono-spaced font. You can specify the Code text
style using the CODE element. To apply the style to a selection of
text, insert the <CODE> tag at the beginning of the selection and the
</CODE> tag at the end of the selection:
• The Emphasis text style marks text for emphasis, and is usually
displayed with italics. You can specify the Emphasis text style using
the em element. To apply the style to a selection of text, insert the
<em> tag at the beginning of the selection and the </em> tag at the
end of the selection:
• The Keyboard text style identifies text to be entered by the user as input,
and is usually displayed with a mono-spaced font. You can specify the
Keyboard text style using the kbd element. To apply the style to a selection
of text, insert the <kbd> tag at the beginning of the selection and the </kbd>
tag at the end of the selection:
• The Sample text style identifies computer output, and is usually displayed
with a mono-spaced font. You can specify the Sample text style using the
samp element. To apply the style to a selection of text, insert the <samp>
tag at the beginning of the selection and the </samp> tag at the end of the
selection:
• The Strong text style marks text for prominence, and is usually displayed
with bold text. You can specify the Strong text style using the strong
element. To apply the style to a selection of text, insert the <strong> tag at
the beginning of the selection and the </strong> tag at the end of the
selection:
• The Variable text style marks text as a variable in a computer program, and
is usually displayed with italics. You can specify the Variable text style using
the var element. To apply the style to a selection of text, insert the <var>
tag at the beginning of the selection and the </var> tag at the end of the
selection:
• The following HTML document uses all seven logical character styles:
Using the • Headings can be used to separate your page into sections. There are
Heading six different heading elements, ranging from h1 (most prominent) to h6
Elements (least prominent). The heading formatting identifies text as headings;
the display size of the heading will depend on the web browser.
• To apply the style to a selection of text, insert the <hx> tag at the
beginning of the selection and the </hx> tag at the end of the
selection. Replace the x with the prominence number you want.
• The following HTML document uses all six heading elements:
Aligning • You can use the align attribute in the hx elements to align your headings.
Headings • To apply an alignment to your heading, insert the attribute align="left" in the
<hx> tag. You can replace left with center, right, or justify, depending on
the alignment you want.
• The following HTM L snippet contains all four heading alignments:
Aligning • You can use the align attribute in the p element to align your text blocks.
Paragraphs • To apply an alignment to your paragraph, insert the attribute align="left" in the
<p> tag. You can replace left with center, right, or justify, depending on the
alignment you want.
• The following HTML snippet contains all four paragraph alignments:
Inserting a • To further organize your page, you can use Horizontal Rules to help
Horizontal break up sections of your page. You can customize the horizontal rule
Rule or hr element by changing the width, thickness, shading, and
alignment options.
• In the HTML document, place the insertion point where you want to
add the Horizontal Rule, and type in the <hr> tag.
To specify a width:
• Type the following, replacing the pixel width of 300 with the value you
want:
To specify a thickness:
• Type the following, replacing the pixel thickness of 5 with the value
you want:
To specify no shading:
• Type the following:
To specify an alignment:
• Type the following, replacing center with the alignment you want:
• If you want to specify more than one hr attributes at the same time,
you can place them all in one <hr> tag. For example, you can use the
following HTML code:
Indenting • You can indent quotations using the blockquote element. The blockquote element
Quotations will indent your text by increasing the left and right margins.
• To indent a selection of text, insert the <blockquote> tag at the beginning of the
selection and the </blockquote> tag at the end of the selection.
• The following HTML snippet uses the blockquote element:
Using the • You can use the Preformatted element to display basic tabular text
Preformatted without using tables. The Preformatted or pre element uses a fixed-
Element width font and displays all regular spaces rather than collapsing them
into a single space.
• To apply the Preformatted formatting to a selection of text, insert the
<pre> tag at the beginning of the selection and the </pre> tag at the
end of the selection.
• The following HTML snippet uses the PRE element: