Unit 5 HTML An Introduction: Structure
Unit 5 HTML An Introduction: Structure
UNIT 5
Unit 5
HTML AN INTRODUCTION
Structure
5.0
Introduction
5.1
Objective
5.2
Introduction to URI
5.3
5.2.1
Fragment Identifier
5.2.2
Relative URIs
History of HTML
5.3.1
5.4
5.5
5.6
5.7
Adding Comments
5.8
5.9
Creating Lists
5.9.1
5.9.2
5.9.3
Nesting Lists
5.9.4
5.9.5
5.9.6
5.9.7
5.10
5.11
5.12
5.13
Page 75
HTML an Introduction
5.14
5.15
Horizontal Rules
Unit 5
5.16
Address Tag
5.17
5.18
5.19
5.20
Marquee Tag
5.21
Self Test
5.22
Exercise
5.23
Summary
5.0 INTRODUCTION
In this unit you are going to learn some basics of HyperText Markup Language
which is used to write HTML documents. Once you create an HTML document it
can be viewed in any browser. There are lot of web sites like xoom.com and
rediff.com, which provide web space for your personal web site. After finsihing
this chapter, you will be able to write web documents. Once you create your web
pages, you can upload these pages to your site using any FTP Software.
This
unit dicusses the basic tags required for creating the HTML document.
You will be learning how to use List and Hyperlink text effectively in your
document. You will also learn to format your document and to include images
in your document. Images will improve the appearance of your document.
Page 76
HTML an Introduction
Unit 5
5.1 OBJECTIVE
After finishing this unit you will be able to:
Discuss about URI
Write your personal web page using Basic HTML elements.
Describe about HTML, BODY, HEAD AND heading elements of web page.
Figure out different HTML tags, including List and Hyperlink text element.
http://www.w3.org/TR/REC-html40/
This URI may be read as follows: There is a document available via the HTTP
protocol, residing on the machine www.w3.org, accessible via the path
"/TR/REC-html40/". Other schemes you may see in HTML documents, include
"mailto" for email and "ftp" for FTP.
You may be familiar with the term "URL" and not the term "URI". URLs are a
subset of the more general URI naming scheme.
Internet, HTML and MultiMedia
Page 77
HTML an Introduction
Unit 5
Page 78
HTML an Introduction
Unit 5
Page 79
HTML an Introduction
Unit 5
Page 80
HTML an Introduction
Unit 5
Attribute: Allows you to specify how web browsers should treat a particular tag.
An attribute is included within the actual tag, either within a start tag or an empty
tag. End tags should not contain attributes.
Syntax:
Attribute = value
E.g., align=center
Starting your Page Document tags: All HTML files should include at least
these tags:
The HTML tag
The HTML Tag: This tag defines the top-most element, identifying it as an HTML
document. It is a container tag that has a start and an end tag and all the other
tags and texts are nested within it.
Syntax: <HTML>
.
</HTML>
The Head Tag: This tag contains information about your HTML file. It may also
contain other tags that helps you to identify your HTML file to the outside world.
The Head Tag is nested within the HTML tag.
Syntax: <HTML>
<HEAD>
.
</HEAD>
</HTML>
Usually, the only tag contained within the head tag is the title tag. Other tags also
can be contained within the head tag but they are used less often.
The Title Tag: This tag is nested within the Head tag. It identifies your page to
the rest of the world. The tag output is displayed on your browsers title bar but
does not appear as part of the page.
Page 81
HTML an Introduction
Unit 5
Syntax: <HTML>
<HEAD>
<TITLE>
Your Title: Describe your title
</TITLE>
</HEAD>
</HTML>
Title tag is a required element that you should include in each and every HTML
document. If you do not include a title, the title of your page appears in some
browsers as Untitled whereas in others just the URL for the page appears on
the browsers title bar.
The Body tag: This tag is the compliment of the Head tag and contains all of the
tags, or elements that a browser actually displays as the body of your HTML
document. Both the Head tag and the Body tag are nested within the HTML tag.
Body tag comes after the head tag, they denote a separate part of the HTML
document.
Syntax: <HTML>
<HEAD>
<TITLE>
My First Web page
</TITLE>
</HEAD>
<BODY>
.
</BODY>
</HTML>
Page 82
HTML an Introduction
Unit 5
You can also use a second-level heading (denoted by the H2 tag) to define a
major division in your page, and a third level heading (using the H3 tag) to define
a sublevel division within a major division. Most browsers support upto six
different levels.
<BODY>
<H1>This is a top-level Heading </H1>
<H2>This is a second-level Heading </H2>
<H3>This is a third-level Heading </H3>
<H4>This is a fourth-level Heading </H4>
<H5>This is a fifth-level Heading </H5>
<H6>This is a sixth-level Heading </H6>
</BODY>
<HTML>
<HEAD>
<TITLE>
MY FIRST WEB PAGE
</TITLE>
</HEAD>
<BODY>
<H1>MANIPAL ACADEMY OF HIGHER EDUCATION</H1>
<P>
Page 83
HTML an Introduction
Unit 5
Manipal has already made a name in imparting professional education not only in
India, but also at the international level. Doctors, engineers, nurses, pharmacists
and other professionals from Manipal have made a mark wherever they have
gone to practice or work.
<P>
The Government of India conferred the deemed University status on Manipal on
June 1993, giving birth to the Manipal Academy of Higher Education, popularly
known as MAHE.
</BODY>
</HTML>
Figure 5.1
Page 84
HTML an Introduction
Unit 5
<HTML>
<HEAD>
<TITLE>
MY FIRST WEB PAGE
</TITLE>
</HEAD>
<BODY>
<H1>MANIPAL ACADEMY OF HIGHER EDUCATION</H1>
<BLOCKQUOTE>
<P>
Manipal has already made a name in imparting professional education not only in
India, but also at the international level. Doctors, engineers, nurses, pharmacists
and other professionals from Manipal have made a mark wherever they have
gone to practice or work.
Page 85
HTML an Introduction
Unit 5
<P>
The Government of India conferred the deemed University status on Manipal on
June 1993, giving birth to the Manipal Academy of Higher Education, popularly
known as MAHE.
</BLOCKQUOTE>
</BODY>
</HTML>
Figure 5.2
Preformatted text : The PRE (Preformatted text) tag is used to display a block
of preformatted text in a monospace, fixed-pitch font. You use the PRE tag to
display a block of text as is, including all spaces and hard returns. One of the
primary uses of the PRE tag is to display text in a tabular or columnar format in
which you want to make sure that the columns remain properly aligned.
Internet, HTML and MultiMedia
Page 86
HTML an Introduction
Example:
Unit 5
<HTML>
<HEAD>
<TITLE>MY FIRST WEB PAGE</TITLE>
</HEAD>
<BODY>
<PRE>
SALES FIGURES FOR FIRST QUARTER OF 1996
---------------------------------------------------------JANUARY FEBRUARY MARCH TOTAL
ANDERSON $ 10,200 $ 20,015 $ 14,685 $ 44,900
BAKER
30,500
25,885
50,225
106,610
PETERSON
15,900
20,115
18,890
54,905
WILSON
40,100
35,000
29,000
104,100
---------------------------------TOTALS
$ 96,700 $101,015 $ 112,800 $ 310,515
</PRE>
</BODY>
</HTML>
Figure 5.3
Page 87
HTML an Introduction
Unit 5
<HTML>
<HEAD>
<TITLE>MY FIRST WEB PAGE</TITLE>
</HEAD>
<BODY>
<OL>
<LI> COMPUTER CONCEPTS
<LI> MS-WINDOWS
<LI> MS-EXCEL
<LI> MS-WORD
<LI> FOXPRO
</OL>
</BODY>
</HTML>
Figure 5.4
Page 88
HTML an Introduction
Unit 5
Notice that the LI tags do not have end tags in this example. The reason is that
the end tag (</LI>), like the end tag for the P tag is implied.
<HTML>
<HEAD>
<TITLE>MY FIRST WEB PAGE</TITLE>
</HEAD>
<BODY>
<UL>
<LI> COMPUTER CONCEPTS
<LI> MS-WINDOWS
<LI> MS-EXCEL
<LI> MS-WORD
<LI> FOXPRO
</UL>
</BODY>
</HTML>
Figure 5.5
Page 89
HTML an Introduction
Unit 5
<HEAD>
<TITLE>MY FIRST WEB PAGE</TITLE>
</HEAD>
<BODY>
<UL>
<LI>SOFTWARE
<OL>
<LI> COMPUTER CONCEPTS
<LI> MS-WINDOWS
<LI> MS-EXCEL
<LI> MS-WORD
<LI> FOXPRO
</OL>
<LI> HARDWARE
<OL>
<LI> CPU
<LI> INPUT DEVICES
<LI> OUTPUT DEVICES
<LI> HARD DISK
<LI> FLOPPY DISK
</OL>
</UL>
</BODY>
</HTML>
Page 90
HTML an Introduction
Unit 5
Figure 5.6
<OL TYPE=I>
<LI>This is item one.
<LI>This is item two.
<LI>This is item three.
<LI>This is item four.
</OL>
Page 91
HTML an Introduction
Unit 5
<HTML>
<HEAD>
<TITLE>MY FIRST WEB PAGE</TITLE>
</HEAD>
<BODY>
<OL TYPE="I">
<LI>LEVEL ONE OUTLINE LEVEL.
<OL TYPE="A">
<LI>LEVEL TWO OUTLINE LEVEL.
<OL TYPE="1">
<LI>LEVEL THREE OUTLINE LEVEL.
<OL TYPE="A">
<LI>LEVEL FOUR OUTLINE LEVEL.
<LI>LEVEL FOUR OUTLINE LEVEL.
</OL>
<LI>LEVEL THREE OUTLINE LEVEL.
</OL>
<LI>LEVEL TWO OUTLINE LEVEL.
</OL>
<LI>LEVEL ONE OUTLINE LEVEL.
</OL>
</BODY>
</HTML>
Page 92
HTML an Introduction
Unit 5
Figure 5.7
Page 93
HTML an Introduction
Unit 5
<HEAD>
<TITLE>MY FIRST WEB PAGE</TITLE>
</HEAD>
<BODY>
<UL TYPE="SQUARE">
<LI>SOFTWARE
<UL TYPE="DISC">
<LI> COMPUTER CONCEPTS
<LI> MS-WINDOWS
<LI> MS-EXCEL
<LI> MS-WORD
<LI> FOXPRO
</UL>
<LI> HARDWARE
<UL TYPE="CIRCLE">
<LI> CPU
<LI> INPUT DEVICES
<LI> OUTPUT DEVICES
<LI> HARD DISK
<LI> FLOPPY DISK
</UL>
</UL>
</BODY>
</HTML>
Page 94
HTML an Introduction
Unit 5
Figure 5.8
<HTML>
<HEAD>
<TITLE>DEFINITIONS LIST</TITLE>
</HEAD>
<BODY>
<DL>
<DT>Hardware
Page 95
HTML an Introduction
Unit 5
Figure 5.9
Page 96
HTML an Introduction
Unit 5
Page 97
HTML an Introduction
Unit 5
Link Target
Link Text
Page 98
HTML an Introduction
Unit 5
Page 99
HTML an Introduction
Unit 5
The common uses for linking HREF and NAME anchors on the same page are:
A directory or table of contents that links to the major headings of a page.
Cross-references between different points in the text.
Links to footnotes at the bottom of the page.
The following is an example of creating a directory or table of contents that will
be displayed at the top of the Web page and that will then link to subheading
sections in the same document.
<HTML>
<HEAD>
<TITLE>Linking Pages</TITLE>
</HEAD>
<BODY>
<H2>USING HYPERTEXT LINKS </H2>
<P>
<A HREF="#PAGE"> LINKING TO ANOTHER PAGE OR FILE </A><BR>
<A HREF="#LOCAT">LINKING TO A PLACE ON THE SAME PAGE </A><BR>
<A HREF="#LOCPG">LINKING TO A PLACE ON ANOTHER PAGE </A><BR>
<H3>
<A NAME="PAGE">
LINKING TO ANOTHER PAGE OR FILE</A></H3>
<P>
YOU CAN FORM A LINK WITH ANYTHING ON THE WEB THAT HAS AN ADDRESS,
OR URL...
<BR>
<H3>
<A NAME="LOCAT">LINKING TO A PLACE ON THE SAME PAGE</A></H3>
<P>
YOU CAN FORM A LINK WITH ANOTHER PLACE ON THE SAME PAGE BY LINKING
AN HREF AND A NAME ANCHOR...<BR>
<H3>
<A NAME="LOCPG">LINKING TO A PLACE ON ANOTHER PAGE</A></H3>
<P>
YOU CAN NOT ONLY LINK TO ANOTHER HTML FILE, BUT TO A PLACE IN THAT
FILE...
</BODY>
</HTML>
Internet, HTML and MultiMedia
Page 100
HTML an Introduction
Unit 5
Figure 5.10
Page 101
HTML an Introduction
Unit 5
<HTML>
<HEAD>
<TITLE>LINK LIST</TITLE>
</HEAD>
<BODY>
<H2>COURSES</H2>
<UL>
<LI><A HREF="DCA.HTM">DCA</A>
<LI><A HREF="PG.HTM">PG DIPLOMA</A>
<LI><A HREF="ADVANCE.HTM">ADVANCED COURSES</A>
</UL>
</BODY>
</HTML>
Figure 5.11
Page 102
HTML an Introduction
Unit 5
A p tag is placed in front of the IMG tag. The IMG tag does not form a new block
element here and would appear on the same line as the text that precedes it (that
is, unless you added the P tag here). In this case, however, you want the image
to appear below the line of text.
Using the ALT Attribute
You use the ALT attribute to provide an alternative to an image in the case of
someone using a text-only browser or using a graphical browser with images
turned off. The capability of turning off the display of images to help pages load
faster.
Example:
Page 103
HTML an Introduction
Unit 5
This will resize the graphics to fit horizontally within a browser window,
regardless of the screen resolution or the width of the browser. The height of the
image will also be resized correspondingly.
Page 104
HTML an Introduction
Unit 5
Page 105
HTML an Introduction
Unit 5
<HTML>
<HEAD>
<TITLE>Deemed University - MAHE</TITLE>
</HEAD>
<BODY>
Page 106
HTML an Introduction
Unit 5
Manipal has already made a name in imparting professional education not only in India, but also at
the international level. Doctors, engineers, nurses, pharmacists and other professionals from
Manipal have made a mark wherever they have gone to practice or work. The Government of
India conferred the deemed University status on Manipal on June 1993, giving birth to the
Manipal Academy of Higher Education, popularly known as Mahe.
<HR>
<ADDRESS>
MANIPAL ACADEMY OF HIGHER EDUCATION
DEEMED UNIVERSITY
DISTANCE EDUCATION WING
MANIPAL
<A HREF="MAILTO:[email protected]">MAHE</A><BR>
</ADDRESS>
</BODY>
</HTML>
Figure 5.12
Page 107
HTML an Introduction
Unit 5
The Mailto: protocol can also be used with HREF tag. When the user clicks this
link, the default mail system is activated. E-mail id specified wit h Mailto: is
automatically placed in the To: Text box as shown in figure below.
Figure 5.13
Page 108
HTML an Introduction
Unit 5
Example:
<HTML>
<HEAD>
<TITLE>MY FIRST WEB PAGE</TITLE>
</HEAD>
<BODY>
<P>This is a regular text. <SUP>Use SUP for Superscripts.</SUP>This is
regular text.<SUB>Use SUB for subscripts.</SUB>This is a regular text. <U>Use
U for underlining. </U>This is a regular text. <STRIKE>Use Strike for
Strikethrough </STRIKE>
</BODY>
</HTML>
Figure 5.14
Page 109
HTML an Introduction
Unit 5
<HTML>
<HEAD>
<TITLE>My Web Page</TITLE>
</HEAD>
<BODY>
<CENTER>
<H2>Level-Two Heading</H2>
<p>This paragraph, and the level-two heading above it, is
centered using the center tag.
<UL>
<LI>First list item
<LI>Second list item
</UL>
</CENTER>
</BODY>
</HTML>
Page 110
HTML an Introduction
Unit 5
<HTML>
<HEAD>
<TITLE>My Web Page</TITLE>
</HEAD>
<BODY>
<p>
<FONT SIZE="1">Font Size 1. </FONT><BR>
<FONT SIZE="2">Font Size 2. </FONT><BR>
<FONT SIZE="3">Font Size 3. </FONT><BR>
<FONT SIZE="4">Font Size 4. </FONT><BR>
<FONT SIZE="5">Font Size 5. </FONT><BR>
<FONT SIZE="6">Font Size 6. </FONT><BR>
<FONT SIZE="7">Font Size 7. </FONT><BR>
</BODY>
</HTML>
Figure 5.15
Page 111
HTML an Introduction
Unit 5
<P>
<Font SIZE=-2>Font size 2.</FONT> <BR>
Manipal has already made a name in imparting professional education not only in India,
but also at the international level. Doctors, engineers, nurses, pharmacists and other
professionals from Manipal have made a mark wherever they have gone to practice or
work.
<BASEFONT SIZE=4>
The SMALL font is the same as a font set with the FONT tags size=2 attribute
value and the BIG font is the same as font set with the FONT tags SIZE=4
attribute value. (The default text font is the same as the FONT tags SIZE=3
attribute value.)
Page 112
HTML an Introduction
Unit 5
<P><FONT SIZE=7>
<FONT COLOR=AQUA>
You can use any one of 16 color names to specify a font color.
</FONT>
Setting the Background, Text, and Link Colors: You can set the colors for the
background, text, and links by using the following attributes of the BODY tag:
BGCOLOR sets the background color
TEXT sets the text or (foreground) color
LINK sets the color of hypertext links
VLINK sets the color of visited links
ALINK sets the color of activated links (when you hold down the mouse
button on a link, without releasing it)
The general form for entering these attributes as color names is:
<BODY BGCOLOR=colorname TEXT= colorname LINK= colorname
VLINK= colorname ALINK= colorname>
Example:
<BODY BGCOLOR=AQUA TEXT=RED LINK=GREEN
VLINK=NAVY ALINK=MAROON>
Page 113
HTML an Introduction
Unit 5
<HTML>
<HEAD>
<TITLE>Deemed University - MAHE</TITLE>
</HEAD>
<BODY background="c:\amritha\formal.gif">
Manipal has already made a name in imparting professional education not only in India,
but also at the international level. Doctors, engineers, nurses, pharmacists and other
professionals from Manipal have made a mark wherever they have gone to practice or
work. The Government of India conferred the deemed University status on Manipal on
June 1993, giving birth to the Manipal Academy of Higher Education, popularly known as
MAHE.
<HR>
<ADDRESS>
MANIPAL ACADEMY OF HIGHER EDUCATION
DEEMED UNIVERSITY
DISTANCE EDUCATION WING
MANIPAL
<A HREF="MAILTO:[email protected]">MAHE</A><BR>
</ADDRESS>
</BODY>
</HTML>
Page 114
HTML an Introduction
Unit 5
Figure 5.16
Page 115
HTML an Introduction
Unit 5
Height, width tag renders itself as a rectangular space on the page. You can
override the default size of this rectangle by assigning values to the HEIGHT
and width attributes. The default value for Height is determined by the font
size of the largest font assigned to the content in the MARQUEE.
Loop = number sets the number of times the Marquee text scrolls its
contents. After the final scroll, the content remains in a still or fixed positions.
If the scroll value is set to 1 or infinite scroll then the MARQUEE text
content scrolls infinitely.
Scrolldelay = milliseconds Increasing the scroll delay value slows the scroll
speed and decreasing the values makes scrolling go faster.
Example:
b. Protocols
c. Hypertext
3. Every resource available on the Web has an address that may be encoded
by a:
a. URI
b. HTTP
c. Both A & B
Page 116
HTML an Introduction
Unit 5
4. The symbol that identifies the HREF attribute as the name of a NAME anchor
rather than an address or filename is:
a. &
b. $
c. #
d. !
6. In 1980,
a. GML
b. HTML
c. SGML
7. The
outside world.
a. Title
b. Body
c. Head
8. There are
a. Three
b. Four
c. Five
d. Six
c. Both a & b
b. <BR>
c. <B>
b. <UL>
c. <OL>
d. <ML>
12. The tag to give visual division between sections of the page, and which
causes the browser to draw an embossed line is;
a. <HL>
b. <HR>
c. <UR>
Page 117
HTML an Introduction
Unit 5
13. For a particular font its size attribute can be an absolute value ranging from:
a. 1-10
b. 1-9
c. 1-8
d. 1-7
14. Which one of the following tags is used to insert graphics in the web page.
a. <IMAGE>
b. <IMAGES>
c. <IMG>
d. <GRAPHICS>
5.22 EXERCISE
Create web pages having the following themes. Web page must look attractive.
A web page describing your town.
Personal web page, giving insight in to your personality.
Web page describing your interests.
5.23 SUMMARY
Now you would have understood what HTML is. Even though there are many
web authoring tools available there is nothing better than having a good
command over Hyper Text Markup Language. In this unit we have discussed
HTML, BODY, HEAD and different HEADING element in great detail. You can
create lists and hyperlinked text that allow you to navigate from one web page to
another.
6. C
11. C
2. D
7. A
12. B
3. A
8. D
13. D
4. C
9. C
14. C
5. D
10. B
Page 118