Introduction To HTML
Introduction To HTML
com
9123820085
INTRODUCTION TO
HTML
kasper-analytics
kasperanalytics.com
9123820085
Introduction
These workshop notes describe how to create simple HTML documents for use on
the World Wide Web. They are intended for people who have never created a Web
page before. Familiarity with using the World Wide Web and a working knowledge
of Windows NT/95/98/2000 are assumed. The material is designed for use on ITS
managed workstations.
Contents
1. Introduction …………………………………………………………………………………………………………………………….2
2. Getting Started………………………………………………………………………………………………………………………..5
3. Creating a Simple HTML Document……………………………………………………………………………6
4. Adding Text to your HTML Document…………………………………………………………………………8
5. Adding Headers to your HTML Document………………………………………………………………10
6. Using Lists…………………………………………………………………………………………………………………………………….11
7. Task 6 Physical and Logical Tags. ……………………………………………………………………………….12
8. Task 7 Using Hypertext Links……………………………………………………………………………………………..13
9. Task 8 Adding Images…………………………………………………………………………………………………………..14
10. Task 9 Creating a Simple Table………………………………………………………………………………………16
11. Task 10 Finding Out More……………………………………………………………………………………………………..18
12. Task 11 Adding a Background Colour……………………………………………………………………………21
13. Task 12 Adding Colour to Text and Links…………………………………………………………………….22
14. Task 13 Adding Background Images…………………………………………………………………………….24
15. Task 14 Adding local Font Settings…………………………………………………………………………………24
16. Task 15 Adding Colour to Tables………………………………………………………………………………………25
17. Optional Task - Checking Your HTML…………………………………………………………………………….27
18. Web Page Design Guidelines…………………………………………………………………………………………….30
19. HTML Resources………………………………………………………………………………………………………………………….31
kasper-analytics
kasperanalytics.com
9123820085
1. Introduction
What is HTML?…
kasper-analytics
kasperanalytics.com
9123820085
Working method…
• Tags are defined using angle brackets, with a formatting code inside:
<BR> is a linebreak, <B> is bold
• Tags come in pairs, acting on everything that they enclose: <B>bold
text</B>
• The closing tag always begins with a forward slash /
o Tags can be in upper or lower case
o Tags can be combined
o They must be nested symetrically:
<P><B><I>bold italic</I></B></P>
• All web pages start with this basic structure of ‘container’ tags
which enclose the entire document:
<HTML>
<HEAD>
<TITLE>Home Page</TITLE>
</HEAD>
<BODY>
</HTML> [email protected]
kasper-analytics
kasperanalytics.com
9123820085
<HTML>
</HEAD>
<BODY BGCOLOR="#FFFFCC">
<H1>Main Heading</H1>
<H2>Subheading</H2>
<P>This is a link:<BR>
</P>
</BODY>
</HTML>
kasper-analytics
kasperanalytics.com
9123820085
2. Getting Started
Objectives Login to the PC network, access the Windows desktop and run the
software to be used in these exercises.
Method: You will login and run the Notepad text editor and Internet Explorer.
2.2
Click on the Start button at bottom left corner of the screen and
select Programs, then Accessories. Click once on Notepad to run the
application. A blank document will be opened.
2.3 Start Internet Explorer by double clicking on the desktop icon, shown left, or use
the Start menu. The opening screen will resemble Figure
Note Switch between applications by clicking on the status bar buttons at the
bottom of the screen.
kasper-analytics
kasperanalytics.com
9123820085
Method You will create a simple HTML document using Notepad, then view
the document using a WWW browser.
<HTML>
<HEAD>
</HEAD>
<BODY>
</BODY>
</HTML>
Note Notice that you have typed in some HTML tags, which are enclosed in
angle brackets e.g. <TITLE>
3.2 Within Notepad, select the File menu and choose the Save option. Choose the
N: drive (for example) and name the file test.htm Make sure that Save as type: is
set to Text Files (*.txt)
kasper-analytics
kasperanalytics.com
9123820085
Note Make a note of where you save your file. You may wish to create a folder in
your My documents folder for the files created in these exercises.
3.3 Switch to the Internet Explorer window (by clicking the button on the status bar
at the bottom edge of the screen)
In the Open window, click on the Browse… button, In the Open window, select the
test.htm file you just saved (you will need to select the N: drive at the top of the
window) and click on the Open button.
In the Open Page window, click on the Open button to open the page in Internet
Explorer.
kasper-analytics
kasperanalytics.com
9123820085
Method You will add some paragraphs separated by carriage returns, and
view them. You will then add the <P> paragraph tag.
4.1 Return to the Notepad window and add only the text shown in bold to your
document (replace John Smith with your own name):
<HTML>
<HEAD>
</HEAD>
<BODY>
John Smith
</BODY>
</HTML>
4.2 Switch to Internet Explorer and click on the Reload icon on the button bar near
the top of the screen.
kasper-analytics
kasperanalytics.com
9123820085
4.3 Return to Notepad. Enclose each paragraph with the <P> and </P> start and
end tags:
<P>John Smith</P>
4.4 Return to Internet Explorer and select the Reload option (F5). Notice that the
three paragraphs are now displayed correctly.
Note WWW browsers use the <P> tag to identify paragraphs. Carriage returns
normally have no effect on the way in which an HTML document is
displayed.
kasper-analytics
kasperanalytics.com
9123820085
Method You will add the <H1> and <H2> header tags.
Comments Headings can be delimited using the <Hn> and </Hn> tags. There are
six different levels, from <H1> the largest, down to <H6>. Header tags
should not be nested.
5.1 In Notepad, add only the text shown in bold to your document:
<HTML>
<HEAD>
</HEAD>
<BODY>
<P>John Smith</P>
</BODY>
</HTML>
5.2 Return to Internet Explorer and Reload your document. Notice how the headers
are displayed differently from the main text.
kasper-analytics
kasperanalytics.com
9123820085
6. Using Lists
Objectives To add a bulleted list to your HTML document.
Method You will use the <UL>, <OL> and <LI> tags.
Comments The <UL> … </UL> tags are used to define the start and end of an
unordered list (bulleted). The <OL> … </OL> tags are used to define
the start and end of an ordered list (numbered). The <LI> tag is used
to define list items.
6.1 In Notepad add only the text shown in boldto your document:
<H2>Summary</H2>
<UL>
</UL>
<OL>
</OL>
kasper-analytics
kasperanalytics.com
9123820085
6.2 Return to Internet Explorer and Reload the document. Notice how the
unordered and ordered lists are displayed.
6.3 Create another ordered list using the <OL>, </OL>, <LI> and </LI> tags.
kasper-analytics
kasperanalytics.com
9123820085
Method You will use <B> (bold), <I> (italic), <STRONG> and <EM> tags.
Comments Physical tags such as <B> and <I> give you control over the
appearance of a document. Logical tags, such as <STRONG> or
7.1 Switch to Notepad and add italic <I> and bold <B> tags to the text as shown
below in bold:
Save the file. Switch to Internet Explorer, Reload the document and view the
changes:
7.2 Return to Notepad and replace the italic <I> tags with the emphasis <EM>
tag, and the bold <B> tags with the strong <STRONG> tag, as shown below:
<STRONG>Notepad.</STRONG></P>
Save the file, switch to Internet Explorer and Reload the document. Notice that the
appearance of the text is the same.
Note Physical formatting tags such as <B> and <I> change the appearance of
text in your document. Logical tags, such as <STRONG> and <EM>, change
the appearance of text too, but they also define the role of the text within
the document.
kasper-analytics
kasperanalytics.com
9123820085
This can be important if your page is read by a text reader for the visually
impaired. If an audio-enabled browser encounters a logical tag, <EM> or
word, whereas physical formatting tags like <B> and <I> will not be
interpreted differently from the rest of the text.
kasper-analytics
kasperanalytics.com
9123820085
Method You will use the <A> anchor tag to add a link to the Birkbeck College
home page.
Comments The <A> tag is used to create links to other files, either locally or on
computers systems anywhere on the Internet.
8.1 Return to your document in Notepad and add only the text shown below in
bold:
<P>John Smith</P>
Save the file and then go back to your WWW browser and select the
Reload option.
Notice how the words Birkbeck College, i.e. the text contained between the <A…>
and </A> tags, is displayed differently from the rest of the text, usually in
underlined blue. If you point the mouse at it the pointer changes to a hand
symbol. This always indicates that you are pointing at a hyperlink that
Note Notice that the <A> tag always uses the syntax
The domain_name is the name of the computer system (Web server) you
wish to access.
The pathname refers to the name of the file you wish to retrieve and the
directory in which it is located.
kasper-analytics
kasperanalytics.com
9123820085
8.2 In Internet Explorer, click on the words Birkbeck College. You will be taken to the
college home page, as shown below:
8.3 Open the View menu and click on the Source option. This allows you to
examine the HTML used in the document you are viewing. This is a useful way to
learn new tags and steal ideas. Close the source window (by clicking on the x in
the top right corner) when you have finished.
kasper-analytics
kasperanalytics.com
9123820085
Comments The <IMG SRC=“...”> tag specifies the location of an image. You will
normally use GIF or JPEG image formats in HTML documents.
9.1 Return to Notepad and insert the following text after the <BODY> tag, as shown
below (it may all fit on one line):
<BODY>
<IMG SRC=“http://www.bbk.ac.uk/images/weblogo220x68.gif”
ALT=“Birkbeck, University of London”>
Save the file and then go to your WWW browser. Use the Back option to re- display
your original page and then select the Reload option. The Birkbeck logo will
appear in your document, as shown below.
Select one of the sets of clipart (by clicking on one of the links to Set-A, Set-B etc.)
9.4 Move the cursor over one of the images and then hold down the right mouse
button. A menu will be displayed (as shown in figure 9-2). Click on the Properties
option.
kasper-analytics
kasperanalytics.com
9123820085
You will now see the properties for that picture, including its address
Highlight the address and copy it (use either right-click – Copy or CTRL+C)
Open the Edit menu and use the Paste option to insert the image’s URL between
the quotes, as in the example shown below (your number will differ):
<IMG SRC=“http://www.ncl.ac.uk/images/gifs4us/Set-B/3.7.gif”>
9.5 Return to the clipart collections and right mouse click on another image. This
time select the Save Picture As.. option, and save it to the same location as your
test.htm file – write your filename below as a reminder; it will be x.x.gif.
My filename is ____________.gif
Add another IMG tag to your page, but this time instead of inserting the full URL,
insert just the filename between the quotes, as in the example below:
<IMG SRC=“2.6.gif”>
kasper-analytics
kasperanalytics.com
9123820085
Note If you refer to an image just by its filename, as above, the image file must
be stored in the same directory as the web page file.
You can also link to images stored in parent directories and subdirectories,
in relation to the location of the HTML file:
<IMG SRC=“images/2.6.gif”>
(The file “2.6.gif” is stored in a subdirectory of the current location, called images)
<IMG SRC=“../2.6.gif”>
(The file “2.6.gif” is stored in the parent directory of the current location)
kasper-analytics
kasperanalytics.com
9123820085
Method You will use a number of basic table tags. These include <TABLE>,
Comments Tables are a useful tool for improving layout and fitting more
information onto a page. Note that old browsers do not support
them, and that they can cause difficulties for audio-enabled
browsers as used by the visually impaired.
10.1 Return to the Notepad program. Select a suitable place in the body of the
document for placing your table and add the following text:
<TABLE BORDER=“1”>
<TR>
<TH>Contents</TH>
</TR>
<TR>
<TD>Task 1</TD>
<TD>Getting Started</TD>
<TD>Page 1</TD>
</TR>
</TABLE>
The <TABLE> ... </TABLE> tag is a container for the whole table.
The <TR> ... </TR> tags define a table row and within this you use the <TD> ...
kasper-analytics
kasperanalytics.com
9123820085
The <TH> tag defines a heading, making the text inside it bold and centred.
Text, images and other HTML tags can all be included inside a table, but must only
be positioned inside the <TD> ... </TD> or <TH> ... </TH> container tags.
10.2 Save your document. Return to your browser and Reload the page. The table
should now appear in your document as shown below:
10.3 You can merge cells of your table using the COLSPAN attribute in the <TR> and
<TH> tags. Return to your document in Notepad and add the text shown below in
bold to the <TH> tag:
<TH COLSPAN=“3”>
kasper-analytics
kasperanalytics.com
9123820085
You can use the ALIGN attribute to position data within each <TD> cell. Add more
rows to your table and experiment with COLSPAN and ALIGN attributes, as in the
example row shown below:
<TR>
<TD>Page 2</TD>
</TR>
or try:
<TR>
<TD>Page 3</TD>
</TR>
10.4 There are other TABLE attributes you can experiment with.
or
Note You need to consider all users when setting table widths. The smallest
screen display generally in use measures 800 pixels wide by 600 pixels
high, so it is generally a bad idea to set a width greater than 760 (allowing
for a scroll bar).
kasper-analytics
kasperanalytics.com
9123820085
<TABLE BORDER=“0”>
To set the spacing between cells (cellspacing) and spacing between the cell
contents and the border (cellpadding), set a distance in pixels, for example:
<TD VALIGN=“top”>
<TD VALIGN=“bottom”>
<TD VALIGN=“middle”>
http://home.netscape.com/assist/net_sites/table_sample.html
kasper-analytics
kasperanalytics.com
9123820085
Method You will access some of the information available on the Web to find
out more about HTML.
Comments Many resources are available to assist Web authors. Some useful
starting points are included here.
http://www.w3.org/MarkUp/
This is a good place for reading about current developments, and you will
also find the official HTML specifications here.
http://materials.netskills.ac.uk/login.html
The Netskills organisation produce a broad range of training materials which can
be used for self training. Birkbeck has a site licence and if you register at this site
you can download the modules. Each module consists of a Powerpoint
presentation and Word workbook and there is a lot there for web authors. To
register to use the materials:
Fill out the form, entering Birkbeck College as the organisation. Click on Proceed
with Registration
Enter a username and password (make one up, don't use a real one), then click
on Continue with Registration.
You will now see the full list of training modules with brief descriptions.
kasper-analytics
kasperanalytics.com
9123820085
Click on the View Module Files button to the left of each title to access the
materials:
Netskills also run excellent HTML authoring workshops, which are highly
recommended. Their current workshop program is listed at:
http://www.netskills.ac.uk/workshops/forthcoming.html
http://www.hotwired.com/webmonkey/teachingtool/
http://www.htmlhelp.org/
You will find lots more at the Yahoo subject index site: http://dir.yahoo.com/
In the Yahoo index displayed on the left-hand side of the page, click on the
Computers heading, and then on the World Wide Web link on the next page. You’ll
find several categories including HTML and Beginners Guides.
kasper-analytics
kasperanalytics.com
9123820085
Method You will set the background colour for an HTML document.
Comments Using a background colour can change the impact of your HTML
<HTML>
<HEAD>
</HEAD>
<BODY>
<H2>This is my document</H2>
</BODY>
</HTML>
12.2 Return to Notepad and replace the <BODY> element with the following:
<BODY BGCOLOR=“#FFDDDD”>
Note the spelling of BGCOLOR. Save the file again, then return to Internet Explorer
and select the Reload button. The background colour should now be pink.
kasper-analytics
kasperanalytics.com
9123820085
http://www.bbk.ac.uk/ITS/html/color/hexrgb.htm
Return to Notepad and try a few of the colours listed in Fig 11-1 by replacing the
value “#FFDDDD” in the <BODY> tag. The hash-mark # is required.
kasper-analytics
kasperanalytics.com
9123820085
Setting colours in the BODY tag will change the text and link colours
for the whole page.
13.1 Use Notepad to open the file colour.htm and replace the opening
13.2 Switch to Internet Explorer and Reload the page. Your document should now
have red text on a white background.
13.3 Return to Notepad and add the following hypertext link to your document,
positioning it inside the <BODY> .. </BODY> tag:
Now add the text shown below in bold to your opening BODY element:
kasper-analytics
kasperanalytics.com
9123820085
13.4 Return to your browser and Reload the page. The hypertext link to Netskills
should now appear as green.
13.5 Return to Notepad and add the text shown below in bold to the BODY
element:
13.6 Return to Internet Explorer and Reload the page. The Netskills link will now
appear in gold when the link has been visited.
kasper-analytics
kasperanalytics.com
9123820085
BODY tag.
14.1 In Notepad, open the file colour.htm and replace the opening <BODY> tag with
the text below:
<BODY
BACKGROUND=“http://www.bbk.ac.uk/ITS/html/color/blue_paper.gif”>
14.2 Return to Internet Explorer and Reload the page. Your page should now have
a blue, textured background.
14.3 In Notepad, replace the image file name ‘blue_paper.gif’ with one of the
following:
yellow_stucco.gif
multidot_paper.gif
pink_fabric.gif
rock.gif
Note Any image can be used as a background, in .gif or .jpg format. Usually it is a
small ‘tile’ that is repeated across the page. A large image will slow the
loading of the page.
kasper-analytics
kasperanalytics.com
9123820085
Comments The <FONT> tag is useful for changing the colour of text
independently of the overall page settings within the <BODY> tag. It
can also be used to change the font size and face.
15.2 Switch to Internet Explorer and Reload the page. Your document should now
have some pink text where you used the FONT tag.
Save your file, switch to Internet Explorer and Reload the page. You should now
have some large and small text.
Note You can set the font SIZE as a number from 1 (smallest) up to 7, or as a
relative value such as ‘+2’ or ‘-1’, in relation to the default text size (which is
‘3’).
kasper-analytics
kasperanalytics.com
9123820085
15.3 We will now try changing the font face. In Notepad, add the following to your
page:
<B>Arial</B></FONT></P>
Save the file, switch to Internet Explorer and Reload the page. The text
above should appear in san-serif style.
Note Not all computers use the same font names. For example Arial, a common
Windows PC font, is often called Helvetica on Macintoshes and ‘sans-serif’
on Unix machines. Therefore, when you use the <FONT FACE attribute it is
advisable to include all the equivalent font names found on different
platforms, separated by commas as in the example above.
15.4 The COLOR, SIZE and FACE attributes of the FONT tag can be combined
together. Try adding the following to your page, or experiment with your own
combination:
kasper-analytics
kasperanalytics.com
9123820085
Method You will use the BGCOLOR=“#rrggbb” attribute of the <TR>, <TD>
<TR BGCOLOR=“#00CCCC”>
</TR>
<TR>
</TR>
</TABLE>
kasper-analytics
kasperanalytics.com
9123820085
Your page should now display a coloured table, with a turquoise row at the top
and a light and dark green cell in the bottom row.
16.3 In Notepad, remove the BGCOLOR attributes from the <TR> and <TD> tags and
add a BGCOLOR attribute to the main TABLE tag as shown below:
Save the file. Switch to Internet Explorer and Reload the page. The whole table
should now have a green background.
16.4 In Notepad, add a BGCOLOR attribute to the first cell as shown below in bold:
<TR>
You should see a green table with a single black cell at top left. This illustrates the
way in which individual cell attributes override the settings in the top-level
<TABLE> tag.
kasper-analytics
kasperanalytics.com
9123820085
Method You will use the ‘Web Design Group HTML validation service’ and
learn what a DOCTYPE tag is.
17.1 Return to the WWW browser and type the following address, known as a URL
(Uniform Resource Locator), into the Location box at the top:
http://www.htmlhelp.org/tools/validator/direct.html
Press the <ENTER> key to visit the site. The WDG (Web Design Group) Validator will
be displayed.
Note There have been several versions of HTML, each of which has added new
features. Level 2.0 is an early version that includes only simple tags with no
tables, frames or fancy fonts. Level 3.2 is the version we are using in this
course, and includes tables, frames and font tags. The most recent version
is HTML 4.0, which comes in two flavours - transitional and strict. Because
there are several versions of HTML in use it is good practice to add a
‘DOCTYPE’ tag at the start of your document to show which version you are
using. In particular, HTML validators require one in order to know which set
of rules to apply when checking your document for errors.
17.2 Return to Notepad. At the start of your document, above the opening
<HTML> tag, add the text shown below in bold (this line must be typed exactly as
shown and is case-sensitive):
Final//EN”>
kasper-analytics
kasperanalytics.com
9123820085
<HTML>
This is the DTD or ‘Document Type Declaration’ for HTML Level 3.2
17.3 In Notepad, select your entire document by opening the Edit menu and
choosing the Select All option. Then select the Copy option, to copy your
document to the clipboard.
Switch to Internet Explorer. Block the entire contents of the validation text
17.4 box, as shown below in Fig 8.1. Then overwrite the contents using the Paste
option form the Edit menu, (or by pressing the CTRL + V keys). This will paste the
contents of your HTML document into the validator form.
your
HTML document
17.5 Click on the Validate it! button (you may need to scroll down to see it.) If there
are no errors in your document the following screen will be diplayed (after a short
wait):
kasper-analytics
kasperanalytics.com
9123820085
Note If you receive a list of errors you should make a note of the first one, return
to the validation form (using the browser ‘Back’ button) and correct it. Then
resubmit the document by clicking on the ‘Validate it!’ button again, and
repeat corrections in this way until all errors are removed. Remember to
apply the changes to your original file in Notepad.
Certain errors can cause a whole series of ‘cascading errors’ and very
often, fixing the first one will also correct the others in the list.
• Most editors will create the opening DOCTYPE tag for you. As we’ve seen in
the previous exercises, a Web page will still display without one so they are
not essential, but must be included if you want to use an online validation
service.
kasper-analytics
kasperanalytics.com
9123820085
• You will find other DOCTYPE tags and descriptions of the differences
between versions of HTML (and lots of reference links) at
http://www.htmlhelp.org/tools/validator/doctype.html
• There is another good validator at http://validator.w3.org/ which can be
used to check live pages on a Web server.
• The WebXact validator at http://webxact.watchfire.com/ will analyse web
pages for their accessibility to people with disabilities.
kasper-analytics
kasperanalytics.com
9123820085
kasper-analytics
kasperanalytics.com
9123820085
A few of the many sites where you can download free icons, graphics and
backgrounds for your web pages:
http://vancouver-webpages.com/META/mk-metas.html
kasper-analytics