HTML Basics
HTML Basics
THE BASICS
WORKSHOP DESCRIPTION
This workshop covers the explanation and basics of HTML. Participants will gain a better idea of how
HTML is used to create a Web page and will gain an understanding regarding the rules and
conventions that must be followed when developing any Web page in HTML. In addition to learning
HTML syntax, participants will learn how to format text in HTML, and learn how HTML is used to create
a hyperlink and include images on a Web page.
PREREQUISITES
Accessibility workshop and an understanding of Windows 95 or higher or Mac OS 8 or higher, basic
computer skills, knowledge of the Web, and basic Web browser skills.
OBJECTIVES
Participants attending this workshop will:
• Learn how HTML is used and the importance of learning it.
• Create a new Webpage utilizing basic HTML commands.
• Format text using various HTML commands.
• Link to other Web site files.
• Include an image in a Web page
The exercises in this document require files distributed during the workshop.
Please make sure that you have a copy of these files.
TABLE OF CONTENT
XHTML, or eXtensible HyperText Markup Language, is a later version of HTML that includes
additional standards set forth by the international organization called the World Wide Web
Consortium (W3C).
Both HTML and XHTML can be understood by most browsers, but for increased accessibility to
your Web pages, we recommend using XHTML when creating your Web pages.
<head>
</head>
<body>
<p>
During the course of this workshop, it is our intention to
teach you how to read and create HTML tags, understand Web page
A basic structure, and <i>build a Web page</i>.
HTML </p>
paragraph
tag. </body>
</html>
Note: Throughout the rest of this document we will use the term HTML to refer to the markup
languages HTML and XHTML.
1
Castro, E. (2003). HTML for the World Wide Web, Fifth Edition, with XHTML and CSS: Visual QuickStart Guide.
• The formatting “rules” (HTML tags) that are applied to content (a syllabus, for example) are
interpreted by programs (browsers) designed to display Web pages as specified by the HTML.
• Because HTML pages (Web pages) are really just text-files they can
be created with a simple text-editor (Notepad, WordPad, TextPad,
SimpleText, Write). HTML editors may not always be available, warranting the use of a text-
editor.
“HTML is not hard to learn or master. It is much more an exercise in careful typing and consistency
than in mind blowing, complicated procedures”.2
2
Castro, Elizabeth, “HTML for the World Wide Web.” 1996. Peachpit Press, Berkeley, CA. P. ix.
Attributes
Many tags have special attributes that offer a variety of options for the contained text. The attribute is
entered between the element word and the final greater than symbol.
Tag attribute
Values
Attributes also have values. These values are the parameters by which the attributes behave (the
value of the attribute defines the attribute). Values should be enclosed in quotation marks.
The text affected by this particular FONT tag will be displayed using an Arial font-face.
Nested Tags
You may want to modify your page contents with more than one tag. For example, you may want to
add bold formatting to a word within a particular font tag.
A
Here order is everything. Whenever you use a closing tag it should corresponding to the last unclosed
opening tag. In other words, first A then B, then /B, and then /A.
<body>
My webpage content
</html>
• The head and body sections are contained within the opening html tag and the closing html tag.
• The Doctype declaration is found at the beginning of every XHTML file. It is the only tag that
can contain uppercase text.
Head Section
• Contains the title of the webpage and information pertaining to the entire Web page.
• Contains any “meta” tags. The meta tag shown in the example below is required in all XHTML
files.
• Nothing in the head section is visible in the browser window except for the title, “My Webpage”
that is found between the title tags (<title>My Webpage</title>).
<title>My Webpage</title>
Body Section
• Contains the file contents that are visible in the browser window. In other words, whatever you
find within the body tags is what you will see in the browser window!
Type <body> to
begin the Web <body>
page content section.
My Webpage content
Type </body> to </body>
close the Web page
content section.
• Viewed in its entirety using a browser, the Web page would look like this:
The content
contained
within the body
tags.
Since HTML files are simply text-files, they can be edited using a text-editor such as Notepad (PC),
WordPad (PC) or TextEdit (Mac).
To open an HTML file for editing, it must be opened directly through a text-editor. To open an HTML
using Notepad or TextEdit:
i. Click on File > Open. From the Open dialog box, using the Files of Type drop
down menu, select All Files:
ii. Using the Open dialog box, browse for the HTML file that you would like to open.
When you have found the file, click the Open button.
i. Click File > Open. Locate your HTML file using the Open dialog box.
ii. Click the Open button in the lower right-hand corner to open the file in TextEdit.
Step 3. Once your file is opened as a text file, you can edit the HTML code.
Step 4. When you have finished editing your file, save it by clicking on File > Save or File > Save
As. The file will be saved as HTML by default.
As a shortcut, you can edit HTML files by right-clicking (or Ctrl+click on a Mac) on the HTML filename.
From the right-click menu, go to Open With… > Notepad or Open With > TextEdit.
Remember – there are two methods of opening an HTML file – from an Internet browser or from a text-
editor.
Step 4. Name your file your_file.htm where your_file is the name of your choice.
NOTE: If you are saving an HTML file for the first time, and are using a Windows machine, you must
select all files next to the “save as type” field. If you miss this step, your file will be saved as a text file
[.txt extension].
Step 2. In your browser select File from the toolbar and choose Open or Open Web Location.
Step 3. In Internet Explorer click on the Browse button; choose the file on your computer that
you would like to view.
Browse button
On Netscape, click on the Choose File button; choose the file on your computer that
you would like to view.
1. From the workshop folder named HTML Basics on your desktop, open the file,
template.htm in Notepad or TextEdit.
2. Identify the structure tags – and the different section that each tag identifies or belongs to.
The most important section to recognize is the BODY section <body…> </body>. Any
content that you want displayed on your Webpage will be entered between these two tags
which identify the body section.
3. Type a title for your page between the title tags (<title> … </title>).
5. Using the Save as option on the File menu of the text editor you are using, save your file in
the HTML Basics folder. Give your file the name structure.htm.
Page Properties
Page properties refer to elements such as page background color, text or link color. These properties
are established within the opening body (<body>) tag.
Example:
Color values can be represented by any of the 16 named colors or a hexadecimal color-code (shown in
example). For further information on color values, see the XHTML Essentials handout that has been
provided to you as part of this workshop.
1. If your file is not already open, open the HTML document from the first exercise,
structure.htm in the text-editor you’ve been working in.
2. Add page properties to the body tag (background and text color).
Advanced
Experiment with different background colors using the color reference in the XHTML Essentials
handout. Use both named and hexadecimal color values.
Example:
<body>
Recommended book: <em>XHTML for the World
Wide Web</em>.
</body>
• Font face: <font face=“name”> (where the face name is a system font)
• Font color: <font color=“color”> (where color can be any of the 16 named colors or a
hexadecimal color-code – see the XHTML Essentials handout)
Example:
<body>
<font face="arial">
</body>
1. Using the text-editor you’ve been working in, open the HTML file from the HTML Basics
folder with the filename index.htm.
2. Format the following text using the HTML tags highlighted in this section:
9 Format the first “Web Accounts:” using a size 5 font. These two
words should also be bold.
9 Within that same paragraph, italicize the second “Web accounts” and the term
“Web servers”.
9 Format the last sentence of the paragraph using a red font color.
Advanced
Add your own content using the HTML tags highlighted in this section as well as those
referenced in the XHTML Essentials handout.
Spacing
Web browsers will ignore extra spaces and returns that exist between the tags in your HTML file.
Browsers treat ALL spaces as one space. To represent spaces in an HTML file, the following tags are
used.
• Line breaks: <br /> (notice that the opening and closing tag are contained within ONE tag)
Example:
<body>
<p><strong><font size="4" color="red">Request CSUS
Web Account</font></strong></p>
<strong>Any Questions?</strong>
<p>Let's continue to Step 2: "Gather
Materials..."</p>
</body>
Alignment
Text within an HTML file can be centered, left justified, right justified or justified. Left justified is the
default.
Example:
<body>
<div align="center">
<p align="left">
<strong>Gather Materials:</strong>
<blockquote>Assignments, Syllabus, Handouts, Textbook
Info Images, Photographs, Data, etc.</blockquote>
</p>
</body>
1. Format the following text using the HTML tags highlighted in this section:
9 Insert an opening paragraph tag right before “Building Your Website”. Close the
paragraph tag directly after the sentence that ends with “…here is what you will
need:”
9 Insert the tag used for a line break directly after each of the comma-separated
items to make each appear on its own line.
9 Center the last two sentences (XHTML is picky…) in the section using the
division align HTML tag or the paragraph align tag.
Other Tags
• Headings: <h1>Heading size 1</h1> (where h1 can be from h1 to h6, h1 being the
largest; headings are always displayed in bold, with a blank line before
and after)
• Horizontal rule: <hr width=“90%” /> (notice that the opening and closing tag are
contained within ONE tag)
Example:
<body>
<h2><font color="red">The Web Process - The Third
Step</font></h2>
<p align="left">
<strong>Text Editors:</strong>
Notepad, TextPad, SimpleText, Write<br />
<strong>Web Editors:</strong>
Macromedia Dreamweaver, Microsoft Frontpage<br />
</p>
<hr width="80%" />
</body>
Exercise 5 –5 Text
Exercise Appearance:
– Text Appearance:Headings
Headingsand
andHorizontal
HorizontalRules
Rules
Using the file you’ve been working with (index.htm), format the following content.
1. Format the following text using the HTML tags highlighted in this section:
9 Format the line of text that begins “Web Page Editing…” using the heading tag
(size 3) HTML tag.
9 On the line following the list, insert the HTML tag for a horizontal rule, using a
width of 80%.
Advanced
Play around with the attributes of the horizontal rule tag, referencing the XHTML Essentials
handout as needed. Try using different heading sizes.
Hyperlinks
Hyperlinks are used to connect files that are on the Web or within a Web site. Hyperlinks can be
clickable text or images within a Web page.
The screenshot below represents a hyperlink that, when clicked, connects the user to another page
within the same Web site.
Creating a Hyperlink
There are two main parts to a hyperlink – the destination and the label. Once the destination (URL)
and label are determined, they are incorporated into an HTML file by using the anchor tag.
open close
destination
anchor tag anchor tag
href label
attribute
Example:
<body>
<h1>Favorite Links:</h1>
<a href=”http://www.csus.edu”>CSUS Homepage</a>
</body>
Hyperlink Types
There are four categories of hyperlinks (links to outside pages, links within a Web site, email links and
anchor links). We will be covering the two most common link types – links to outside pages and links to
pages within a Web site.
The first type of hyperlink is one that points to a file located outside of your Web site.
http://www.csus.edu/web/
root directory
index.htm
images
banner.jpg
Hyperlink icon.gif
within Web site week1
to “outside”
source. wk1_lesson1.htm
wk1_lesson2.htm
week2
wk2_lesson1.htm
The second type of hyperlink points to a file located inside of your Web site.
OR
OR
<a href=”../help/index.htm”>Help</a>
NOTE: The sequence “../” is used to denote that the file is located one directory up from the
current location.
root directory
index.htm
images
banner.jpg
icon.gif All hyperlinks
week1 point to a file
within the
wk1_lesson1.htm Web site.
wk1_lesson2.htm
week2
wk2_lesson1.htm
Exercise 6: Hyperlinks
Exercise 6: Hyperlinks
Utilizing the information you just learned regarding hyperlinks, recreate the section entitled
Sample Links (from the file index.htm) using the following guidelines:
Step 1: Make each of the lines under the heading entitled “Sample Links” a link:
a. Locate the text that reads “Sample HTML document structure”. This text should be a
link to the HTML structure document you created in the first exercise. Using the anchor
tag, create a link using the text “Sample HTML document structure”. The URL
(destination) for the hyperlink should be “structure.htm”.
Step 3: Save your file in the HTML Basics folder on the desktop.
Advanced
Add links to your favorite Web sites in the Sample Links section!
To include an image on a Web page, you’ll need to use the image tag. Before we proceed, here are
the specifics on the image tag (notice that the opening and closing tag are contained within ONE tag):
where:
image_path (attribute of the <img> tag) is the location (or path) of the image. For example,
images/banner.jpg. This example represents a relative path to the file. This
attribute is REQUIRED.
height The height of the image. This tag can be used to promote a faster download of
the image. This attribute is NOT required. However, it should be included.
width The width of the image. This tag can be used to promote a faster download of
the image. This attribute is NOT required. However, it should be included.
alt_text (attribute of the <img> tag) the text that will be displayed by text Web browsers
such as LYNX and used by screen readers. On some browsers, the text that
appears within the alt attribute will display when the mouse cursor is held
stationary over the image. The alt attribute contains a description of the image.
Align Used to align the text appearing directly after the image tag. Align can be set to
left, right, and center.
border A border can be placed around an image. If you use your image as a link, you
will need to set the border attribute of the image to 0 – unless you want a blue
border around your image.
root directory
index.htm In Browser…
image
banner.jpg
icon.gif
When an image file is located within your Web site (or directory), the value for the src attribute of the
<img> tag should be relative. One of the most common problems is when img src values are
indicated in the absolute, like this: C://mydocs/images/smiley.gif.3 This will be a problem when the
Web site is moved to a server.
Here is an example of the src attribute using a relative URL for the image:
3
This type of absolute path will only exist when the image file is located on the local computer..
Okay, now it is your turn to try inserting an image that is located within your Web site directory…
Step 1. Insert the image of the Web Design banner located in the images folder in
the HTML Basics folder (images/banner.gif). This image should appear in
the same place as the one displayed on the Web Design handout.
Advanced
Add in some of the other images located within the images folder.
Use the hyperlink tag to make the Sac State banner image at the top of your page a link to
Web Central (http://www.csus.edu/web).
1. Using Internet Explorer, open the file, “index.htm”, from the HTML Basics folder.
Navigate through your “Web site”, noting how the content is formatted.
2. Using Netscape Navigator, open the same file, “index.htm”, from the HTML Basics
folder. Navigate through your “Web site”, noting how the content is formatted.
3. Compare the view of your Web site offered by both browsers. Minimize the screens and
compare them side-by-side as done in the last example featuring Netscape 6.2 and
Internet Explorer 6.0.
Are there any differences? Can you accommodate for any differences?