Rudiments of Computer Science
TG Le,
EMO ME MIDI 2 ws mney
Timers 192
Dern nny rr
verso
wey wet oon
Seopa rs
‘wows es
rane
Sen enter
is
Thr a tre
Yorn oT
yeni Hn
ftom 20
TML or Hypertext Markup Language is one of the most Wit the fa form of HTM, ey
Tr erroon nrg net ceed See est [eRe aut] nt
nd we pages. Asamarkip langage the puposcofHTML | iseicaweamecnsn 2 | Ses asin
trond ase of general rust dermine how neopae | ieseeeatyat™ || Sense _]
content should look when displayed ina browser. tis made up | _Svetetekrtmo'css? | | ummm
Perey ae eee
and when used, they crete a specific output inthe browacr window. Joumet sien
Apart rom ITM, oer anguages used for designing web pages include JavaSerpt, Caseading, Mra Oe 707
Style Sheets (CSS) and PHP. Although you may find other languages, these are the primary ones | atx sande foin doe
used to deliver content through a Web browser. Word soxument omat
JavaScript is similar to traditional programming languages but allows Internet users to perform | ysscat ot Kes)
certain actions on a website and interact with the content. It uses function calls and supports object- | and Exc! (atx es.
oriented programming clements. CSS is a complementary language that helps to style HTML
‘markup code. PHP isan acronym for ‘PHP: Hypertext Pre-processor’.Itisa server-side scripting
language embedded in HTML and does all the processing on the server side rather than inside the
browser, before a web page is rendered, Perl is another server-side programming language used for
1 wide range of tasks including web development, as itis compatible with HTML and XML.
Another language, Extensible markup Language or XML |
plays a significant role in present day web development. | “<>
Trallows the exible development of user-defined <{umBBniss tertesques/n
document types and in web application, its commonly ‘Seaman
tused to transport data fiom one application or script wo
another. Like HTML, XML is also used to format a -<¥aamises
document with a web browser. However, it is not a fA |
replacement to HTML (sample XML code shown above).
PA a
HTML is. formatting language used to create documents containing hypertext for the World Wide |
‘Web. It was developed in the early 1990s by Tim Berners Lee.
= Function: A Web page written in HTML gives a general guideline on how to present a given
Web document. The Web browser program translates this guideline and displays the contents of
the HTML page with the best display possible on the available hardware.
ry :
105 Pora7
Part 2: Chaptor7
© Structure: Each HTML document has two main parts, a
hhead and a body. The head part contains information to
identify the particular web page and the body contains the
information which gets displayed in the browser window.
HTML pages are saved as files with the extension .htm or
-html in the appropriate directory on a Web server.
iar mnpt oan
wt dose '
ainassmpntmar
$ Geman ante 3
4 nt odo ph
inn Mf
$n acorn i
8 Erp eng oo i
i
{nati ypeskeg?
+ Component Stat bento erg HTM,
—e
in its simplest form an HTML document is
Fragen — || made up of elements called tags that are generally used to
LTnetearegenealy |) format the HTML document. HTML tags are not ease
| used to format the sensitive and are enclosed by angular brackets like “<’ and *>" as in , ,
,
|itidrame:A | | Ata ean also hae one or more tributes that are wed 0 se the properties of ap
For example, in the statement , the bgcolor attribute makes the
background colour ofthe body as “blue”. When a Web browser downloads an HTML page trom
a Web server, it interprets the tags and displays the document with the appropriate formatting
Depending upon its function, an HTML tag can either be a container tag or an empty tag,
e a. Container Tag: A container tag comes in pairs with an opening tag like indicating the
start of the formatting and a corresponding closing tag like indicating the end of the
‘within pa of angle
ContainerTag formatting. Note that the closing tag starts with a forward slash. For example, the code
eeepc <TEST will display the text written within the and tags i.e. TEST in bol.
opening tag tie |b, Empty Tag: In contrast, an empty tag is @ single tag and does not contain anything It his
<> inde te some function ofits own and has only an opening tag. For example, the
or break as
‘an empty tag that introduces a line break in the displayed document.
oes
| corresponding = Formatting Features: Apart from formatted plain text, HTML allows numbered lists, bulleted
eesepteate <> |] etter graph sound tote mere wing appropriate ap For esample ings
the formating, computer.jpg> will insert the picture file computer,jpg stored under the current directory.
‘= Hyper-linking: One of the most important features provided by HTML is hyper-linking. Using
this feature the user can move to other relevant web pages by simply clicking on a hyperlink
ina given page, without the need to type the URL of that page.
Benefits of HTML: The popularity of HTML can be due to some of the reasons as stated below:
1. The Internet forms a logical network connecting computers with different configuration.
HTML unifies such a diverse system with a standard language that can be used in any operating
system platform,
b. HTML is supported by all the browsers and most web development tools
¢. Use Hyperlnking helps o easily link one document to another
4. HTML is easy to understand, leam and use
e
f
8
Empty Te9
an empty tg isa
| single tag and does
| not contain anything
| and as ony an
pening tag ike
>
Being plain text, itis simple to edit
‘The text being compressible, itis fast to download
HTML is Free
Bp | + Limitations
Limitations of | a. Limited Scope: Its not a software programming language and lacks the advantages of such®
HTML full-fledged language. Neither is it a desktop publishing tool like MS Word.
b. Static Data: Data displayed in a normal HTML file is static in nature and cannot be moditieé
by another process.
106Rudiments of Computer Sclence on
Pee nN
The fllowingseation gives a general guldeline to design {G
Tage nM a ercet www vest | | Structure of 3
simple Web pages. As stated earlier in HTML angle brackets Spscltrca? 7 web page
‘<> are used to elose special codes called tags, that are used to | ymamycuns mea,
do different formatting and organisational tasks. HTML | &Vhtstepurms!eto
consists of many such tags which are discussed below eerie
- e
imag
- is the most important tag in a web page. It is used to idemity the page as a web page. All | isused to ent
content within an HTML document must occur between the opening and closing tags page as awed
7
SIT
‘Two oter important tas ina web page ae the and tgs. [aie &
The head of a web page is placed at the beginning of the page and reac | 5 | theheadtagis
describes the general properties ofthe page. tis conned within the | Sjang, 772 | peat
and tags. The tag ean contain two more tags. | beginning of the |
These ae the andthe tags The ext placed within the | uy» |_| | abies
title tg is displayed inthe ttle bar of the browser. sade” gia popes
* The body appears below the head and contains the actual content of | and tags. |
e
boy? toa
‘The tag contains the
sctual content ofthe
page displayed by
‘A sample Web page showing the use of the above tags is given below, The output is also shown,
Jo
—
Jo ening HTML <>,
Bate!
map |
sen dona ent —e—
a bee ;
used to create a web page that incudes ‘canbe wed tm create web page that aches frmaned text, mage, aad | | tag
Seat trometer || Seon Fear
— |S tee og
iapayea ne
sto
a cave
tim Eee
(pen Notepad or any ober ext editor and ype the HTML code as shown above, Note how the tags
suiputed tthe cole The indentations are wed fo make the code eal readable. After ypings | 3,
Se ereate a folder called WebSite and save the lini by typing thee nae a work hum
te bar ofthe
Working with
-xt open the saved file using any Web browser. The output will be as shown above. Note that
[Next open the saved file using any Web browse put ove. Note thatthe | Working with
text ‘Learning HTML placed within the tag is displayed in the title bar. Whatever is written
‘within the opening and closing tags is then displayed as the main content of the web page.
‘Note that the line breaks in the actual code may not match the line breaks in the displayed text.
[As has been discussed earlier, a tag can also have one or more attributes that are used to set the
properties of a tag. There are various attributes that are possible for the tag. These are
Acscribed below in a tabular form and their use shown. You can open the work/.hémt file in notepad
and apply each attribute to the body tag and see the result
107Part 2: Chapter 7
| eee
Attributes ortne | [PECoIOr [This s used fo set the colour forthe background ofthe page | body becolor “CVA
" tag | [backgroud [Used o put an mage for the background ofthe web page. | =body backsvound = pict
ext Tiss sed fo set the colour a the text inthe page Body text= BLUE
ink Fie colour or any un-vised linkin he page (def Due) | body link = GREEN
| [atime Defines the colour for an active fink inthe page (default red) | “body alink = GREEN
ink The colour fr any visited ink nthe page (default purple) [body vlink = BLUE
| [leftmargin | Sets the left-hand side margin of the page body lefimargin = 30>
ropmargin | Ses the top margin ofthe pase body topmargin= 20
color atrote bgcolor attribute of body ta Qe
This atbuteof | Colour canbe applied tothe background of a web page using the
tedviagiswsedto |) bgcolor attribute along with the tag. Note that the
aoalycdortotbe | speling of the word is color and not colour in bgcolor. The
background ofaweb} | Fotiowing example colours the background of the web page CYAN (sky blue).
page
pie Ge (ectmewes even ex)
tle» Learing HTML
tim»
— | + background attribute of body ta
This atibuteof || One can also use an image as a background. It can be done by using the background
|tsdytg ined |) acribute along with the name ofthe image file. Inthe example shown below, the image
|eseanimage 2 || file flowerjpg (see figure onthe right) is used asthe background image. Place the imi
[piec™et2¥] chat you want to se, in the same folder where the web page is saved. The image tiles ——
itself automatically and fills the entire background.
-
‘hie an elementary course on HTML.
‘eathes some of te basi tags tat can be
sod create a web page that includes
formatted text, mages, and inks to ther
“isis cemetary cone ce HTML teaches sme te bc gt
‘abe ed cee ab pe a ca fom pa
One ean also use the hexadecimal colour values in place of the colour names. Each colour canbe
expressed as a combination ofthe three colours Red, Green, and Blue. The values are given ©
P274
108uiments of Computer Science wr
#RRGGBB where the proportion of cach colour is expressed by combination of two hexadecimal
Aigits representing cach primary colour. Examples of some of the standard colour names and their
corresponding hexadecitnal values are given below. One can either use the names or the
hexadecimal values inthe colour cove. The user ean also ereae his own colour shade outside the
standard colours, by changing cach hexadecimal digit rom 0 tT
Co Cd
xCK [#000000 [MAGENTA |i Fo0rr 0000 JRED—_[FFuN00
[WEFEFFE [#08080 jio0080 [ORANGE | F8000
#OOFEFE 00 FOO os000 [TEAL _|o0s040
H0000FF HAATOO xooos0 —[vELLOW |rrfrro0
The following example shows how the bgeolor attribute ean be Creer
used along with a colour number. The example displays the te cap a? 1 [| textatbute
background colour ofa page in ORANGE hex value FFHOO} | oniyuomesa ums | ils atta
| simaistepupise detctranie || Boe at
‘gates Titoeeitsccgcc” | | ete
«text attribute of body tag See Tees |
The text atibute is used t denote the default ext colour ofa document The following example
puts the text colour to blue:
+ ink, alin, and link attributes of body tag
‘The link stribue is sed to denote the colour of a hyperlink inthe document. The default colour is
blue. The alink attribute is used to denote the colour of an active hyperlink i.e. the colour of a link | | body tag is used to
when iti clicked. The default colour is red. The vlink attribute is used to denote the colour ofa | eet the colour ot
Visited hyperlink inthe document. The defaut colour is purple. In case one wants to change the | hyernkin the
default colours, one can do so by specifying the desired colous as
+ eftmargin, and topmargin atibutes of body tag:
‘The leftmargin attribute is used tose the left-hand side margin forthe web page and the topmargin | 2935 used
attribute is used to set the top margin of the web page. The example shown below has set the left | Sracove ype
‘margin to 80 pixels and the top margin to 40 pixels.
cs peer rr’
o nk tbe
cheat |
This atrbut of
“cte> Leaing HTML ee
ody tag is used to
con denote the colour ot
Visited byperinkin
‘he ls an otmontary course on HTML {the documet
{aches som of te basic tgs at can be
Used to create a web pape thal includes
orate txt, mages, and Inks other
Given below is an example of the body tag with all the attributes used as discussed above, Note
thatthe attributes are optional and one can selectively use them.
75
109 'Comment tag
‘
Part 2: Chapter 7
AMT -
In ease the user wants to write something that should not
appear in the browser window, then the comment tag
‘The tag can also be used to insert a comment as shown below:
Type your comment here
The tag is the paragraph tag and is used to separate one paragraph from another. The pair
of paragraph tags
and
are used to enclose and demarcate a section of text as a paragraph,
It ereates a double space around the text in a paragraph.
Note: One cannot insert a new-line by simply pressing the ENTER key. This is because all extra
‘white spaces like spaces, tabs and new-lines are removed from the text when itis displayed by the
browser. Therefore, one has to use the or
tags to insert a new-line.
Open Notepad and type the following example, Save the file as work2.hkaml and open the file in
‘your browser to view it, Note that the output does not show the paragraphs as displayed in the source
file. The writing is shown as a continuous text without any paragraph demarcation,
shim
"thea
‘iie>Uso of Paragraph Tag
head
(Chandrasia Treks a popular trek in
Garmwal Himalayas.
\Chandeasila summits a rock ace above
{he tompo of Tungnath the highest of a
{he temples nthe Hralayas.
“The Chandrashis summit afords the mast |
‘esuit view of Nandoden, Tish, Kedar |
Peak and Chaukharoa peaks.
| Next open the work2./um1 file and insert the tags as shown below. Save the file and open it
using your browser. Observe how the output has changed, with spaces around each paragraph.
"choad
“tile>Use of Paragraph Tag
™
“Chandrashia Tok sa popular ok in
Garwal Himalayas
| ‘
Chandrasia summits a ook faco
above tho temple of Tungnath, te highest
fal the temples inthe Himalayas
Chad stmt rec ie shove te ep of Taga height
‘
The Chandeashia summit fords the| ffl epee Hae,
‘Most Beau view of Nandacav, Trish
Fe ee ee ot anced, TROL He Cane ment ir he ext bn vw da,
“et Kd Peas Che pee
stron»
2-7-6
140uuliments of Computer Science wr.
* align attribute ofthe paragraph
ty: Wa pan ip a
(One can use the rt py sign stots
Hea aibute ofthe paragraph ago 1M, | fe
center, or right align a paragraph. Note the spelling of the erect poroggh a? 2
attribute valve for cenrng i enter and notcente. Open | 2twnmecitin i
Notepad and type the following example showing the use ofthe | rawr" || regi atgna
‘
alignment attributes. Save the file as work3.Juml and open | 5 ¥heheadea oy woes elses} | pareaneh
itusing your browser. The following output will be displayed. fare mien ee
a
rchead>
“iteParseraph Agron»
——
Note: You can also use the
tag as Center Aligned Text to align text
to the centre ofthe page. However, this is done usually using the tag as discussed later.
<
‘The
or the break tag is used for a line break ic, the web browser interprets this tag as a | Line break tag
request for a new line and moves down a line before displaying the next line of text. It is usually | <™
inserted atthe end ofa line and is used to insert line break or oe of more blank lines between two | -__@
lines of text. This tag is an empty tag and does not have an ending tag. Open Notepad and type the || iyg
following example showing the use ofthe
tag. Save the ile as workshtmd and open it wing | Tyg
your browser. The following output will be displayed: |
reaktag
[andi an empty tag
| tsedtora ine break
hin
"head
ile Uoe of break tagetile>
ody |
“IRE and tLe |
‘acc and J wont up he hile
Toren palo of water
Se
“Tk ft down an broke nis cownebe>
‘Andi came uneling aer
[See omere eee
“The headline tag is used to apply @ heading or headline to a page. There are six different pre-defined | Headline tag
hheadtine text sizes that are possible. These are given as , , ..... , Of these, is |
the largest size and isthe smallest size heading.
The following example shows the effect of using these. Open Notepad and type the following
example showing the use ofthese tags. Save the file as workS.html and open it wih your browser to
view the result,
P21
m1