Chapter 8
Chapter 8
Learning Objectives
Get familiar with
HTML
components that make up HTML code
Know about the
HTML code
to be followed while writing
List the rules
view an HTML document
Create, save and
structure of an HTML document
Understand the
You can accesS millione
life.
important part of everybodys
loday, the Internet has become an Internet. Do you know how these
web pages are
on the computers on the
of web pages stored can be used by
simple language is Hypertext Markup Language (HTML) that
developed? One
a 'novice to develop web pages.
Lee in late 1991, but the first
standard HTML specification
HTML was created by Tim Berners-
version HTML 4.01 was published in
late
HTML 2.0 was published in 1995. Another major
versions. Currently, we have HTML
5.0 version
1999. It is one of the most widely used HTML
which was published in 2012.
An
HTML tag starts with a less than sign () followed by the tag name and ends with a greater
than sign For example, <P> is an HTML tag used to create a paragraph.
()
An
HTML element usually consists of a
starting (or opening) tag and an ending (or closing)
tag, with the content inserted in between. The closing
the opening tag except
tag is similar to
itis preceded with a forward slash (/). The HTML element is everything from the opening tag
to the closing tag.
Empty element: An HTML element that has only the opening tag is called an empty
element. For example, the <BR> tag, which is used to insert a line break, is an empty
element and does not require a closing tag.
HTML Attributes
Attributes provide additional information about HTML elements. They are always specified
nside the opening tag after name. Each attribute has a name and a value.
the tag
Example:
117
HTML Rules
these rules are
While writing HTML code, you need to follow certain rules. Some of istea
below
sensitive. That is, whether
whet you
HTML tag names and attribute names are not case se write
SBODY>, Body> or <body>, all mean the same.
spaces. The browser does not reee
e writing tags, the tag names cannot contain wrong output. For exampl
the tag havingsspaces in it and consequently it displays the nple,the
browser considers<P >as an incorrect tag
an element can contain one or m.
The HTML elements can be nested. This implies that underlinede
nore
you want to make some text bold and
cicments within it. For example, if you
Can use both <B> and <U> tags together, as shown
below,
HTML Editor
An HTML editor is a software application used to create and save HTML documents. There are
two main types of HTML editors: WYSIWYG and text editor.
wYSIWYG (What You See Is What You Get) editor: This editor provides a graphical
interface and tools that let you develop web pages quickly and easily. You need not write
the HTML code; rather, you can directly insert images, hyperlinks or tables whatever you
want in your web page and the code is generated automatically. 1he main advantage ofthis
editor is that you can create web pages without having knowledge of HTML tags. Some
examples of WYSIWYG HTML editors are Adobe Dreamweaver, Microsoft Publisher
and Google Web Designer.
Text editor: You can also use a text editor such as Notepad or WordPad to write and modify
the HTML tags. However, in this case, you must have the knowledge of HTML tags.
ExTRA
DoSE!
Earlier, Microsoft FrontPage was one of the most widely used WYSIWYG
HTML editors. But, now it has been discontinued.
118
Creating and Saving HTML Documents
can
use either WYSIWYG or text editor to create an HTML document. Let us learn how to
Jou HTM document using Notepad.
createan
HTML document using Notepad, follow these
create aand save an
To
steps.
click the Start button and then click All Programs.
<HTML
EAD>
TITLEMY FIRST WEB PAGE</TITLE>
/HEAD
<BODY>
ALL THE WEB PAGE CONTENT GOES HERE
/B00Y
/HTML>
Click the File menu and then click Save As. The Save As dialog
box appears.
3Deme
4
Comu
s Hiden
Type a suitable name for the document with extension .htm or .html in the File name text
box and then click Save.
NoTE
While saving a document, if you do not use the .htm or .html extension with the
name, the document is by default saved with .txt extension.
119
Viewing HTML Documents Explorer, Googl.
browser, like Internet
document in any web displays oni
IML web browser, it
or Mozilla Firefox. When a web page is viewed in the formatted according to the gven
Mos
Or
y
1nformation (without the tags, elements and attriou
or elements. follow these steps.
lo view your created HTML document in
Internet Expo
Press Ctrl+ O on the keyboard. The Ope Type the irtemet addressda
open for you.
documer
tme
dialog box appears.
Bpiorer wl t
Click Browse. The Windows Internet Explorer
gpen
e My fist we page
Libranes
Documents
Open
Music
Pictures Typethe irtemet address d a documert and iten
Videos Epiorer wil open it foryou
Homegroup
Computer
pen: D:My folderHTAML code y fiest web page he
a New Volume D)
120
NoTE
NOTTf you make any changes in the HTML code written in the Notepad, you need not
close the Notepad program. You can switch to the web browser and press
the F5
key to view your most recent modifications.
KHEAD
<TITLE> . </TITLE>
/HEAD
KBODY
</BODY
</HTML
HTML Element
HTML document and defines the document as
The HTML element is the first element in an
and ends
starts with <HTML>
an HTML
file. It is a container element. Every HTML document
HEAD and BODY elements, which in turn,
with</HTML>. An HTML element contains only
contain other elements.
HEAD Element
identification and additional information about the HTML
The HEAD element includes the
within this element is not displayed
document, such as title and keywords. The content written
on the web page. It is also a container element.
TITLE Element
web page. The title of the
The container element that provides a title for the
TITLE element is a
web page is displayed in the title bar when you view the page in
a browser. The TITLE element
BODY Element
Lne BODY element has the main content of the web page. It includes text, images, tables, links,
121
etc. It is a container element. The CBODY> follows </HEAD> and </BOD ODY> appears
BODY
before </HTML>. Al other elements are enclosed within <BODY> and </BO tags
backgroundndimag
The BODY element has many attributes that can be used to specify the
colour of the web pag left margin and top margin of the web
as well. Let us learn about these attributes.
page, and the alignment
e
Background Attribute
for the web page. You can u
ne Dackground attribute is used to specify the background
which is tiled across the web
image or text (convert into an image) as the background
Syntax:
SBODY BACKGROUND="URL or path/filename">,.../BODY>
where,
as
ORL Or path/filename is the location of the image which is to be placed
background of the web page.
For example, the following HTML code sets the image of a moon and stars as the backgroung
of the page.
CHTML>
<HEAD>
<TITLE>Moon and Stars</TITLE>
</HEAD>
BODY BACKGROUND-"D: \My folder\stars . jpg">
</BODY>
</HTML>
e dS d
122
Bgcolor Attribute
The
he alor
bgcolor((background colour) attribute
isused to specify thebackground
web ge
By default, the background
colour of the web page is white.
colour for the
Syntax
<BODY BGcOLOR=
or colou name">.
where S/BODY>
rggbb is a six-digit hexadecimal number
All wsers do not understand the
colour names, Hence,
acimal
hexade (hex) number. This
number is formed by the
colours are represented
s
andi
deternmined using
the formula ot #RRGGBB,
combination of red,
where RR is the hex value
as a
green and blue
value for green and B is the hex value for blue. for red, GG is the
These numbers are always
a#symbol, preceded with
Text Attribute
The text attribute is used to specitythecolour for the text in the web page. By default, the text
colour of the web page is black. Like background colour, the text colour is also
represented in
hexadecimal numbers.
Syntax:
TITLE>Introduction to HTML</TITLE
</HEAD>
TEXT="WHITE" LEFTMARGIN="30
<BODY BGCOLOR="BLUE"
TOPMARGIN="30">
HTML isa computer language used to create Da.
web page
for display very easy tO understand and
on wWW. It is
use. Different conponents that togetner maKe up the HTML
Hmu
TEACHER'S NoTE
Discuss with students the basics of HTML.
Explain to them the structure of an HTML document.
TIME FOR EXERCISES
Fill in the blanks.
a. HTML describe how a web page should be displayed.
b. The content written within element is not displayed on the web page.
125
web browser how parto
is the special code that describes to the s of
the HTML document are to be processed.
HTML elements
provideadditional information about
(ii) ii)
0)
a web page?
e. Which HTML element is used to give title for
(i) TITLE (ii) HTML
(0) HEAD
<TITLE>
HEAD>Our National Flower</HEAD></TITLE>
<BODY BGCOLOR="1otus .jpg" TEXT="RED">
Put a
. tick () for the correct statements and a cross (x) for the wrong ones.
A Before using HTML, you must have knowledge of any other programming
language.
b. Define element.
d. Write any two rules that are to be followed while writing HTML code.
6Application-basedquestions.
a. Kanan wants to create an HTML document but she does not have much knowledge of
HTML tags.
6) Which type of HTML editor should she use to create the document?
Manoj is designing a web page in which he wants to set background colour to orange. Can
you tell which attribute he should use to do this?
127
below. Ohe.
Observe the
the figure given figure
page as shown in been used to create this web
web
C.
cated a web two attributes that have
Deepika has crea page
par
y three elements and
Foaits Windows nteet opiorer
RevisioniClus 74TML Pegesi
Chapten htm Page Safey Tools9
2himanshulEploring I7 C
Zd ggested Stes We Sca Galey
Y
Fevonts 1
2
Frols
ILOVE FRUT
0-
Done
Internet |
Protected Mode On 123%