Chap 8 - Introduction to HTML
Chap 8 - Introduction to HTML
INTRODUCTION TO HTML
Class: Comp. Sc A/L By:
By NDANG George
Welcome to HTML Basics. This lesson leads you through the basics of Hyper Text Markup Language (HTML).
HTML is the building block for web pages. You will learn to use HTML to author an HTML page to display in a
web browser.
Objectives
By the end of this topic, you will be able to:
- Describe the structure of a webpage using HTML
- Use a text editor to author an HTML document.
- Be able to use basic tags to denote paragraphs, emphasis or special type.
- Create hyperlinks to other documents.
- Create an email link.
- Add images to your document.
- Use a table for layout.
- Apply colors to your HTML document.
Prerequisites: You will need a text editor, such as Notepad and an Internet browser, such as
Internet Explorer or Netscape.
Table of Contents
I. INTRODUCTION ............................................................................................................................... 2
II. CREATING, SAVING AND VIEWING A HTML DOCUMENT ............................................. 2
III. FORMATTING A WEB PAGE..................................................................................................... 5
IV. CHARACTER FORMATTING TAGS ........................................................................................ 8
V. HTML LIST....................................................................................................................................... 11
VI. HTML IMAGE .............................................................................................................................. 12
VII. HTML LINK ................................................................................................................................. 15
VIII. HTML TABLE .......................................................................................................................... 17
I. INTRODUCTION
HTML (Hypertext Markup Language) is used to create document on the World Wide Web. It is simply a
collection of certain keywords called “Tags‟ that are helpful in writing the document to be displayed using a browser
on Internet. It is a platform independent language that can be used on any platform such as Windows, Linux,
Macintosh. To display a document in web it is essential to mark-up the different elements (headings, paragraphs,
tables, and so on) of the document with the HTML tags. To view a mark-up document, user has to open the
document in a browser. A browser understands and interpret the HTML tags, identifies the structure of the document
(which part are which) and makes decision about presentation (how the parts look) of the document.
HTML also provides tags to make the document look attractive using graphics, font size and colors. User can
make a link to the other document or the different section of the same document by creating Hypertext Links also
known as Hyperlinks.
HTML tags are not case sensitive. <B>means the same as <b>. But the World Wide Web Consortium (W3C), the
group responsible for developing web standards, recommends lowercase tags
<HTML>
<HEAD>
II.2- Basic structure of an HTML document .............
</HEAD>
The essential tags that are required to create a HTML document are: <BODY>
.............
Any HTML document then has the following structure
</BODY>
The <HTML> tag encloses all other HTML tags and associated text within your document. It is an optional tag.
You can create an HTML document that omits these tags, and your browser can still read it and display it. But it is
always a good form to include the start and stop tags.
Step-3: Save the file as myfirstpage.html(go to File-Save As-give File name: myfirstpage.html choose save as
type: All Files-click save)
Step-4: Viewing document in web browser (open Internet Explorer-click on File-Open-Browse-select the file
myfirstpage.html-click open-click ok)
Browsers ignore extra space within HTML document Browsers ignore any additional space you
type, and compress the text as if the space did not exist. For Example:
This code Would display
“My FirstPage” “My First Page”
Browsers ignore your extra line and paragraph breaks. Generally you press enter when you want to create line
and paragraph breaks, but they won‟t show up when you view the document in browser.
Tag Description
<html> Defines an HTML document
<body> Defines the document's body
<h1> to <h6> Defines header 1 to header 6
<p> Defines a paragraph
<br> Inserts a single line break
<hr> Defines a horizontal rule
<!--> Defines a comment
a) Heading <H1>.............<H6>
HTML has six header tags <H1>, <H2>...........<H6> used to specify section headings. Text with header tags is displayed in
larger and bolder fonts than the normal body text by a web browser. Every header leaves a blank line above and below it
when displayed in browser. For example, the following code
<HTML>
<HEAD>
<TITLE>
Section Heading
</TITLE>
</HEAD>
<BODY>
<H1> This is Section Heading 1 </H1>
<H2> This is Section Heading 2 </H2>
<H3> This is Section Heading 3 </H3>
<H4> This is Section Heading 4 </H4>
<H5> This is Section Heading 5 </H5>
<H6> This is Section Heading 6 </H6>
</BODY>
</HTML>
Would display
This code
<h5 align="left">I can align headings </h5>
<h5 align="center">This is a centered heading </h5>
<h5 align="right">This is a heading aligned to the right </h5>
Would display
b) Paragraphs:
This tag <P> indicates a paragraph, used to separate two paragraphs with a blank line. Think of a paragraph as a
block of text. You can use the align attribute with a paragraph tag as well.
This code
<p align="left">This is a paragraph</p>
<p align="center">this is another paragraph</p>
Would display
This is a paragraph
this is another paragraph
c) Line Breaks
The empty tag <BR> is used, where the text needs to start from a new line and not continue on the same line.
To get every sentence on a new line, it is necessary to use a line break.
d) Horizontal Rule
The <hr>element is used for horizontal rules that act as dividers between sections, like this:
The horizontal rule does not have a closing tag. It takes attributes such as align and width.
<HR> accepts following attributes:
SIZE: Determines the thickness of the horizontal rule. The value is given as a pixel
value.
an exact width of HR in pixels, or a relative width as percentage of the
WIDTH: Specifies
document width.
ALIGN: Set the alignment of the rule to LEFT, RIGHT and CENTER. It is applicable if it
is not equal to width of the page.
this attribute is used; it specifies that the horizontal
NOSHADE: If a solid bar is required,
rule should not be shaded at all.
COLOR: Set the color of the Horizontal rule.
Example
This Code Would Display
<hr align="center" width="50%"
size="3" noshade color="blue">
e) Comments <!--……..-->
The comment tag is used to insert a comment in the HTML source code. A comment can be
placed anywhere in the document and the browser will ignore everything inside the brackets.
You can use comments to write notes to yourself, or write a helpful message to someone looking
at your source code.
Notice you don't see the text between the tags <!--and -->. If you look at the source code, you
would see the comment. To view the source code for this page, in your browser window, select
View and then select Source.
Note: You need an exclamation point after the opening bracket <!--but not before the closing bracket -->.
<PRE> tag can be used, where it requires total control over spacing and line breaks such as
typing a poem. Browser preserves your space and line break in the text written inside the tag.
Example:
The character formatting tags are used to specify how a particular text should be displayed on
the screen to distinguish certain characters within the document. The most common character
formatting tags are:
Font Colours and Size <font> …..</font> specify the colors and/or size of the text.
• color: Sets the color of the text that will appear on the screen.
• size: Sets the size of the text, takes value between 1 and 7, default is 3. Size can also be
set relative to default size. For example; size=+X, where X is any integer value and it
will add with the default size.
• face: Sets the normal font type, provided it is installed on the user‟s machine.
Example:<FONT FACE="ARIAL"> the text will be displayed in Arial</FONT>
Colors are defined using a hexadecimal notation for the combination of red, green, and blue
color values (RGB). The lowest value that can be given to one light source is 0 (hex #00). The
highest value is 255 (hex #FF). This table shows the result of combining red, green, and blue: A
collection of color names is also supported by most browsers.
HTML Backgrounds
The <body>tag has two attributes where you can specify backgrounds. The background can be
a color or an image.
Bgcolor: The bgcolor attribute specifies a background-color for an HTML page. The
value of this attribute can be a hexadecimal number, an RGB value, or a color name:
<body bgcolor="#000000">
<body bgcolor="rgb(0,0,0)">
<body bgcolor="black">
The lines above all set the background-color to black.
Background: The background attribute can also specify a background-image for an
HTML page. The value of this attribute is the URL of the image you want to use.If the
image is smaller than the browser window, the image will repeat itself until it fills the
entire browser window.
<body background="clouds.gif">
<body background="http://profdevtrain.austincc.edu/html/graphics/clouds.gif">
The URL can be relative (as in the first line above) or absolute (as in the
second line above).
Special character
There are certain special characters that can be used while creating
document. Following are some special character
Symbols Entity
©, ® ©, ®
¼, ½, ¾ ¼, ½, ¾
†; ˂; ˃; ≤; ≥ ÷, <, >, &le, &ge
& &
♣♠♥ &spades, &clubs, &hearts
All these special character must
V. HTML LIST
HTML Supports several ways of arranging items in lists. The most commonly used are:
Ordered list also called as Numbered list, is used to present a numbered list of item in the order
of importance or the item (paragraph) is marked with a number.
An ordered list starts with the <ol>tag. Each list item starts with the <li> tag.
Attribute Description
Type = A Capital letter eg. A, B, C………
Type = a Small letter eg. a, b, c,………
Start: used for lists that need to start at values other than 1. start always specified in
default numbers, and is completed based on TYPE before display, For example, If start
=5 it would display either an „E‟, „e‟, „V‟, „v‟, or „5‟ based an TYPE attribute.
An unordered list is a list of items marked with bullets (typically small black circles). An
unordered list starts with the <ul>tag. Each list item starts with the <li>tag.
It is an empty tag(only start tag, no end tag) and is written as: <IMG SRC = image_URL>
SRC is the Source of the image file and image_URL represents the image file with its location.
Not only does the source attribute specify what image to use, but where the image is located. The
above image, graphics/chef.gif, means that the browser will look for the image name chef.gif in
a graphics folder in the same folder as the html document itself.
src="../../../other/images/chef.gif"
means this goes multiple layers up.
This SRC attribute is mandatory for the <IMG> tag. Other attributes used with <IMG> are:
- Align
- Height and width
- Vspace and hspace
- Alt
- Border
a) ALIGN:
used to set the alignment of the text adjacent to the image. It takes the following values:
• ALIGN = LEFT - Displays image on left side and the subsequent text flows
around the right hand side of that image
• ALIGN = RIGHT - Displays the image on the right side and the subsequent
text flows around the left hand side of that image
• ALIGN = TOP - Aligns the text with the top of the image
• ALIGN = MIDDLE - Aligns the text with the middle of the image
• ALIGN=BOTTOM - Aligns the text with the bottom of the image
Height and Width of an image can be controlled by using the height and width attributes in the
<IMG> tag as follows:
White space around an image can be provided by using hspace (Horizontal Space) and vspace
(Vertical Space) attributes of the <IMG> tag. These attributes provide the space in pixels.
This attribute is used to give alternative text that can be displayed in place of the image. This is
required when the user needs to stop display of images while retrieving a document in order to
make the retrieval faster, or when the browser does not support graphics. It is also used a tool
tips – displaying description of the image when the mouse is over the image.
e) BORDER
Border around the image can be controlled by using BORDER attribute of <IMG> tag. By
default image displays with a thin border. To change the thickness or turn the border off, the
value in pixels should set to BORDER attribute. E.g.<IMG SRC=NOSlogo.GIF BORDER=0>
Example
<html>
<head>
<title> use of img tag with its align attribute</title>
</head>
<body>
<p>
<img src="placide/profile.jpg" align=top> aligns the text with the
top of the image
</p>
<p>
<img src="placide/profile.jpg" align=middle> aligns the text with the
middle of the image
</p>
<p>
<img src="placide/profile.jpg" align=left> displays image on left
side and the subsequent text flows around the right hand side of that
image. displays image
on left side and the subsequent text flows around the right hand side
of that image. displays image on left side and the subsequent text
flows around the right hand side of that image.
</p>
<p>
<img src="placide/profile.jpg" align=right> displays image on right
side and the subsequent text flows around the left hand side of
that image. displays image on right side and the subsequent text
flows around the left hand side of that image.
</p>
</body>
</html>
Example:
- Within the same document:<A HREF="#section_name">
- Same folder, but different document:<AHREF="document.html#section_name">
- Different folder, different document:<A HREF="folder/document. html#section_name">
- A different server:<A HREF="http://www.nios.ac.in/foldername/ document.html #section_name>
Example
<HTML>
<HEAD>
<TITLE> Use of Anchor Tag</TITLE>
</HEAD>
<BODY>
<H2 align="center"><U><FONT COLOR="BLUE">National Institute of Open
Schooling</FONT> </U></H2>
<A HREF="http://placide.blog4ever.com"><IMG SRC="placide/profile.jpg"
alt="Jesus is love" align="left"></A>
The success of open learning and distance education very much depends on the
harnessing of the new and latest technology. The emerging Internet and Web
Technology helps in effective dissemination of information. The web
site isa demand source of latest information. One can access NIOS website
by clicking on <A HREF="http://www.placide.blog4ever.com" >Blog de
planette</A> OR on Clicking on my picture.
You can also contact me by clicking here <a
href="mailto:dzplacide@gmail.com">Contact me by mail</a>
<p></p><p></p><p></p><p></p>
<p><b><i><u>Internet and Web Technology</u></i></b></p>
<p><FONT COLOR="BLUE">Various Terms used in Internet are:</FONT><br>
<ol type = "i">
<li><A HREF="#HTML"> HTML(Hypertext Markup Language) <br>
<li><A HREF="#WWW">WWW(World Wide Web)<br>
<li><A HREF="#site">Web site</A>(Linking within the document)<br>
</P>
<P></P><P></P><P></P>
<A NAME="HTML">HTML (Hypertext Markup Language)<a> <hr align="left"
width="24%" noshade> HTML (Hypertext Markup Language), Language used to
create document on the World Wide Web. It is simply a collection of certain
key words called Tags
href="http://en.wikipedia.org/wiki/Html">
http://en.wikipedia.org/wiki/Html</a> to
read more</strong> </p><p></p>
<A NAME="WWW">WWW(World Wide Web<a><hr align="left"width="17%" noshade>
<p>The <B>World Wide Web</B> (''<B>WWW</B>'' or
Example
<html>
<head>
<title>My First Web Page </title>
</head>
<body>
<table border = "5" width="90%" cellpadding="5" cellspacing="0"
> <tr bgcolor="#EDDD9E">
<td width="200" valign="top"><img src="placide/profile.jpg"
width="100" height="100"></td>
<td valign="top"><h1 align="right">Placide
DZEUGANG</h1> <h3 align="right">Computer
Scientist</h3></td>
</tr>
<tr>
<td width="200">
<h3>Menu</h3>
<ul>
<li><a href="home.html">Home</a></li>
<li> <a href="faq.html">FAQ</a></li>
<li> <a href="contact.html">Contact</a></li>
<li> <a href="http://www.placide.blog4ever.com">My
Blog</a> </li>
</ul>
</td>
<td valign="top">
<h2 align="center">Welcome!</h2>
<p>Welcome to my first webpage. I created this webpage without the
assistance of a
webpage editor. Just my little text editor and a keen understanding
of html.</p>
<p>Look around. Notice I'm able to use paragraphs, lists
and headings. You may not
be able to tell, but the layout is done with a table. I'm very
clever. </p>
<blockquote>
<p>I always wanted to be somebody, but now I realize I should have
been more specific.</p>
<cite>Lily Tomlin </cite> </blockquote>
</td>
</tr>
</table>
<hr width="90%" align="left">
<address>
Placide DZEUGANG<br>
Computer Scientist<br>
512.555.5555
</address>
<p>Contact me at <a
href="mailto:dzplacide@gmail.com">dzplacide@gmail.com</a> </p>
</body>
</html>