Web Technologies Notes
Web Technologies Notes
A. Bhagya
MCA, M.Tech
Available Books for B.Sc (OU) III-Year VI-Semester
Mathematics (Numerical Analysis)
Mathematics (Generic Elective-2 : Elements of Number Theory)
Mathematics (SEC-4G : Switching Circuits)
Mathematics (SEC-4H : Graph Theory)
Mathematics (DSE-1F/A : Complex Analysis)
Mathematics (DSE-1F/B : Vector Calculus)
Physics (Paper-VII : Modern Physics)
Chemistry (Paper-VII : Chemistry-VII)
Computer Science (Computer Networks)
Computer Science (Generic Elective-2 : Information Technologies-2)
Computer Science (SEC-4G : Python-2)
Computer Science (SEC-4H : Information Security)
Computer Science (DSE-1F (Elective-A) : PHP with MySQL)
Computer Science (DSE-2F (Elective-B) : Web Technologies)
Statistics (Design of Experiments, Vital Statistics, Official Statistics and Business Forecasting)
Electronics (Digital Communication)
Botany (Paper-VIII : Plant Physiology)
Botany (Paper-IX (Elective-III) : Tissue Culture and Biotechnology)
Zoology (Paper-VII : Immunology and Animal Biotechnology)
Zoology (DSE-II(A) Paper-VIII : Aquatic Biology)
Despite every effort taken to present the book without errors, some errors might have crept in. We
do not take any legal responsibility for such errors and omissions. However, if they are brought
to our notice, they will be corrected in the next edition.
Web Technologies is the programming concept that allows users to create interactive web pages. These pages can
be created by writing code using various web programming languages like XML, HTML, JavaScript, VBscript, Perl
and PHP. A web document can be created using client-side and server-side programming languages and are later
embedded within HTML documents. In client-side programming, the execution of program/script is done on client
machine. Some of the client-side programming languages are HTML, JavaScript, CSS etc.
Cascading Style Sheets (CSS) is one of the most interesting concepts of HTML as it specifies the rules for organ-
izing elements of a given web document. CSS are used to determine the style and layout of web pages. JavaScript
is a programming language with direct support to object-oriented methodologies. It facilitates inclusion of certain
executable data along with it. Hence, it can be said that with the usage of JavaScript, a given web page will no longer
remain a store house of static data but it can also maintain dynamic data which can interact with the users, it can
dynamically create HTML context and also control the browser actions.
According to the examination pattern of B.Sc students, this book provides the following features:
v List of Programs are provided before the units for easy reference.
v Every unit is structured into two main sections viz. Short Questions and Essay Questions with solutions
along with Learning Objectives and Introduction.
v Objective Type along with Very Short Answers are also given at the end of each unit.
v Three Model Papers are provided in order to help students to understand the paper pattern in the end examination.
v Lab Practical with Solutions are also provided at the end of units.
v Important Questions are included to help the students to prepare for Internal and External Assessment.
The table below gives complete idea about the subject, which will be helpful to plan and score good marks in their
exams.
Unit
Unit Name Description
No.
This unit includes topics like Structuring Documents for the Web:
Creating Links with the <a> Element, Advanced E-mail Links. Images,
Structuring Documents for the Web, Audio and Video: Adding Images Using the <img> Element, Using
Links and Navigation, Images,
1. Images as Links, Image Maps, Choosing the Right Image Format,
Audio and Video, Tables, Forms,
Frames Adding Flash, Video and Audio to Your Web Pages, Table: Introducing
Where you Can Add CSS Rules, CSS Properties: Controlling Text,
the Box Model, More Cascading Style Sheets: Links, Lists, Tables,
2. Cascading Style Sheets Outlines, The :focus and :activate Pseudo Classes Generated Contents,
with CSS, Page Layout: Understanding the Site’s Audience, Page Size,
3. JavaScript, Putting Your Site on Working with JavaScript: Practical Tips for Writing Scripts, Form
Site on the Web: Meta Tags, Testing Your Site, Talking the Leap to
Live, Telling the World about Your Site, Understanding Your Visitors.
It is sincerely hoped that this book will satisfy the expectations of students and at the same time helps them to score
maximum marks in exams.
Suggestions for improvement of the book from our esteemed readers will be highly appreciated and incorporated
in our forthcoming editions.
Web Technologies
B.Sc III-Year VI-Semester (OU)
CONT ENT S
Syllabus (As per (2016-17) Curriculum)
List of Programs L.1 – L.2
INTERNAL ASSESSMENT 76 - 78
Structuring Documents for the Web: Introducing HTML and XHTML, Basic Text Formatting, Presentational
Elements, Phrase Elements, Lists, Editing Text, Core Elements and Attributes, Attribute Groups.
Links and Navigation: Basic Links, Creating Links with the <a> Element, Advanced E-mail Links.
Images, Audio and Video: Adding Images Using the <img> Element, Using Images as Links, Image
Maps, Choosing the Right Image Format, Adding Flash, Video and Audio to Your Web Pages.
Tables: Introducing Tables, Grouping Section of a Table, Nested Tables, Accessing Tables.
Forms: Introducing Forms, Form Controls, Sending Form Data to the Server.
Frames: Introducing Frameset, <frame> Element, Creating Links Between Frames, Setting a Default
Target Frame Using <base> Element, Nested Framesets, Inline or Floating Frames with <iframe>.
UNIT-II
Cascading Style Sheets: Introducing CSS, Where you Can Add CSS Rules.
CSS Properties: Controlling Text, Text Formatting, Text Pseudo Classes, Selectors, Lengths, Introducing
the Box Model.
More Cascading Style Sheets: Links, Lists, Tables, Outlines, The :focus and :activate Pseudo Classes
Generated Content, Miscellaneous Properties, Additional Rules, Positioning and Layout with CSS.
Page Layout: Understanding the Site’s Audience, Page Size, Designing Pages, Coding Your Design,
Developing for Mobile Devices.
UNIT-III
Learning JavaScript: How to Add Script to Your Pages, The Document Object Model, Variables, Operators,
Functions, Control Statements, Looping, Events, Built-in Objects.
Working with JavaScript: Practical Tips for Writing Scripts, Form Validation, Form Enhancements,
JavaScript Libraries.
Putting Your Site on the Web: Meta Tags, Testing Your Site, Talking the Leap to Live, Telling the World
about Your Site, Understanding Your Visitors.
MODEL QUESTION PAPERS WITH SOLUTIONS COMPUTER SCIENCE PAPER-VIII (B)
FACULTY OF SCIENCE
MODEL
PA P E R 1
B.Sc. (CBCS) VI-Semester Examinations
Subject: COMPUTER SCIENCE
DSE-2F: Web Technologies
Paper-VIII (B)
SECTION - A ( 5 × 3 = 15 Marks )
Answer any Five of the following Eight questions. Each carries Three marks.
2. Write about the tags used for creating table. (Unit-I, Page No. 3, Q4)
4. What is a selector? List the types of selectors in CSS. (Unit-II, Page No. 81, Q5)
6. What is a variable in java script? How to declare a variable (Unit-III, Page No. 174, Q3)
7. Write a short note on meta tags. (Unit-III, Page No. 175, Q9)
8. What are head, title, body tags in HTML? (Unit-I, Page No. 4, Q7)
SECTION - B ( 3 × 15 = 45 Marks )
Answer all of the following Three questions. Each carries Fifteen marks.
OR
(b) Explain how basic table is created in xhtml. (Unit-I, Page No. 46, Q48)
10. (a) How style sheets are specified into HTML document? (Unit-II, Page No. 82, Q12)
OR
(b) Explain in detail about background properties of CSS3 with an example. (Unit-II, Page No. 117, Q29)
11. (a) How a script is added to the webpage. (Unit-III, Page No. 176, Q13)
OR
FACULTY OF SCIENCE
MODEL
PA P E R 2
B.Sc. (CBCS) VI-Semester Examinations
Subject: COMPUTER SCIENCE
DSE-2F: Web Technologies
Paper-VIII (B)
Time: 2 Hours Max. Marks: 60
SECTION - A ( 5 × 3 = 15 Marks )
Answer any Five of the following Eight questions. Each carries Three marks.
SECTION - B ( 3 × 15 = 45 Marks )
Answer all of the following Three questions. Each carries Fifteen marks.
9. (a) Discuss about presentational elements. (Unit-I, Page No. 15, Q20)
OR
(b) What are different types of Form controls in xhtml? (Unit-I, Page No. 56, Q55)
10. (a) Explain how the fonts can be controlled. List and explain each of the properties
that directly affect the font and its appearance. (Unit-II, Page No. 89, Q18)
OR
(b) Discuss in brief about the composition and grids. (Unit-II, Page No. 142, Q44)
11. (a) What is an operator? What are the different types of operators? (Unit-III, Page No. 188, Q21)
OR
(b) What are the two different states of testing? Explain about validating
HTML, XHTML and CSS. (Unit-III, Page No. 243, Q51)
FACULTY OF SCIENCE
MODEL
PA P E R 3
B.Sc. (CBCS) VI-Semester Examinations
Subject: COMPUTER SCIENCE
DSE-2F: Web Technologies
Paper-VIII (B)
Time: 2 Hours Max. Marks: 60
SECTION - A ( 5 × 3 = 15 Marks )
Answer any Five of the following Eight questions. Each carries Three marks.
3. List the properties that influence the appearance of the font. (Unit-II, Page No. 80, Q4)
4. What are the different properties that are used to position the items on the page. (Unit-II, Page No. 81, Q7)
5. List the advantages of fixed-width design and liquid design. (Unit-II, Page No. 81, Q10)
7. Write a short note on domain name. (Unit-III, Page No. 175, Q12)
SECTION - B ( 3 × 15 = 45 Marks )
Answer all of the following Three questions. Each carries Fifteen marks.
9. (a) Explain about images and supported attributes in HTML. (Unit-I, Page No. 30, Q31)
OR
10. (a) Discuss in detail about the dimensions of a box. (Unit-II, Page No. 111, Q27)
OR
(b) Write in detail about layout of forms. (Unit-II, Page No. 165, Q66)
11. (a) Write about form validation. (Unit-III, Page No. 219 , Q33)
OR
(b) What are the different pointers used to make more people aware of the site? (Unit-III, Page No. 250, Q57)
VERIFICATION, VALIDATION
UNIT STRUCTURING DOCUMENTS
AND
THE SOFTWARE
WEB,
FOR
LINKS AND TESTING,
NAVIGATION,
IMAGES, AUDIO
MEASUREMENT ANDAND VIDEO,
METRICS FOR
3
1 TABLES, FORMS, FRAMES
ASSOSSING SOFTWARE QUALITY SIA GROUP
LEARNING OBJECTIVES
After studying this unit, a student will have thorough knowledge about the following key concepts,
INTRODUCTION
HTML is a markup language immensely used to develop web pages. It creates a web page with the help of in-
built tags, which are the special keywords supported by HTML. The most commonly used HTML tags include
<HTML>---</HTML>, <HEAD>---</HEAD>, <BODY>---</BODY>, <TITLE>--- </
TITLE> etc. HTML supports formatting tags which are used for designing and coloring the text. A hyperlink
creates a link. This link directs the users to another HTML page or to any specific part of a web page or the
same webpage. An image tag or <img> tag inserts an image in HTML page.
In HTML, data can also be represented in the form of a table consisting of rows and columns. The HTML
table is created using <TABLE>…</TABLE> tags. Form is a web page which contains elements like text
fields, check boxes. Usually forms are created by inserting<FORM>---</FORM> tags in the HTML code.
The output screen of every HTML application is referred as a frame which is defined as the region of the
browser that displays certain output.
PART-A
SHORT QUESTIONS WITH SOLUTIONS
Q1. Write about different formatting tags.
Answer : Model Paper-III, Q1
Formatting the text/content present in a web page can be done through formatting tags. Various formatting tags in HTML
are as follows,
1. Paragraph
The tag <p> allows the text to be written in a paragraph (i.e., block-wise).
2. Center Tag
The tag <center> allows the text to be written in center of a page.
3. Break Tag
The tag <br> shows a line break.
4. Bold Text
The tag <b> displays the text in bold format.
5. Italic Text
The tag <i> displays the text in italicized format.
6. Marked Text
The tag <mark> displays the text by highlighting or marking it.
7. Underlined Text
The tag <u> displays the text in underlined format.
8. Subscript
The tag <sub> displays the text in the subscripted format.
9. Superscript
The tag <sup> displays the text in the superscripted format.
Q2. Write about various controls of forms.
Answer : Model Paper-I, Q1
<ul> Frame
The output screen of every HTML application is
<li> . . . </li> nothing but a frame. Hence, frame can be define as the part
<li> . . . </li> of the browser that displays a particular output. Here, each
</ul> independent frame can display an independent “HTML” file.
Hence within a single window, various files can be viewed at
Example
one glance.
o item Example
o item Frame.html
2. Ordered Lists <HTML>
<HEAD>
Ordered list is used to display list items with order.
<TITLE> Frame </TITLE>
Ordered list is usually initiated using the tags <OL type
</HEAD>
= “value”> text to be displayed </OL>. These lists are
<BODY BGCOLOR = “pink”>
used when user is willing to display lists sequentially
<CENTER> <STRONG> <H1> FRAME example </
each list item preceeded with <li> . . . </li>, default
sequence is number. It can be customized using type
H1> </STRONG> </CENTER>
attributes <ol type = “1|A|a|i|I”> value is the first char-
</BODY>
acters of sequence. </HTML>
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 3
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Mainframe.html Q8. Define the structure of html program.
<HTML> Answer :
<HEAD> The structure of a basic HTML document is given below,
<TITLE> inserting frame</TITLE> <HTML>
<FRAMESET ROW = “25%”> <HEAD>
<FRAME SRC = “frame.html”> <!— A HTML comment—>
</FRAMESET> <TITLE> A HTML Document </TITLE>
</HEAD> </HEAD>
</HTML> <BODY>
Q6. Explain <img> tag in HTML. ...
Answer : Model Paper-III, Q2
...
Image tag is used to add an image to the page. This is </BODY>
done by providing suitable image source and image file format
in the tag. </HTML>
Syntax Q9. What is hyperlink? Explain the anchor tag with
syntax.
<img Src = “location of the image”/name of the image”>
Answer : Model Paper-II, Q8
Attributes supported by the image tag are,
Hyperlink
(a) src
A hyperlink directs the users to another HTML page
(b) Alt
or to any specific part of a web page or the same webpage. A
(c) Align hyperlink allows users to navigate between various parts of
a web page or different web pages. It allows users to create
(d) Border
hyperlinks using text/images available on webpage.
(e) Hight /Width
Anchor Tag
(f) Hspace/Vspace
In HTML, a link is defined using <a> tag. <a> is an
(g) Longdesc anchor tag. The code for creating a link is embedded between
the tags <a> ... </a>.
(h) Name.
Q7. What are head, title, body tags in HTML? The syntax of creating HTML tag is as follows,
of the HTML code i.e., title, link, meta are same of the tags that By using font tag, the style and size of the text can be
appears in the head region of the html document. changed. The attributes of the font tag are size and color which
Title Tag are shown below,
<TITLE> ……</TITLE> the name of the document <font size = “[t/ – ]n” color = “# rrggbb” >
which is displayed at the title bar of the html document is This tag sets the font size to the text. It has highest
provided using <TITLE> tag. It is an optional tag. priority than the default value or any size set by <basefont>
Body Tag i,e., it changes the font size to a particular size by modifying
the <basefont> size or default size.
<BODY> ……</BODY> it is the major tag which holds
the data and elements on a web page. It holds eight attributes. The size attributes uses the numbers from 1 to 7 for
They are : background, bgcolor, bottom margin, left margin, tag absolutes font sizes but for relative sizes it uses t/ – 1 to 7.
margin, right margin, text, scroll respectively. These attributes For example: <font size = “+5” Font </font >
can make the representation of elements depending on the
requirement. It displays font with size 5.
4 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-1 COMPUTER SCIENCE PAPER-VIII (B)
PART-B
ESSAY QUESTIONS WITH SOLUTIONS
1.1 STRUCTURING DOCUMENTS FOR THE WEB
HTML
HTML stands for HyperText Markup Language. It is markup language immensely used in developing web pages. In
similar way, the Hyper Text Markup Language highlights different views of a given web page in terms of headers, titles, plain
text, images, sounds etc.
HTML creates a web page with the help of numerous in built tags. A tag is nothing but a special keyword and instruction
supported by browser.
Considerations to be taken while creating a HTML page,
Every HTML code should begin with <HTML> tag and end with </HTML> tag.
Every HTML code should be saved by .HTML or .HTM extension.
There is no specific editor devised for writing HTML codes, i.e., a given HTML code can be written on a simple notepad.
The output of a given HTML document can be visualized by typing the path (where a given HTML document has been
saved) along with .HTML extension on the address bar of any web browser (internet explorer, netscape navigator etc.)
If the browser is not displaying expected output then, it means that the HTML code contains certain errors which should
be sufficiently debugged.
It has to be noted that the HTML language is not case sensitive, hence writing the code either in upper case or lower
case will make no difference.
Steps for Writing a HTML Program
Step 1
To write a HTML program, open a suitable notepad. This can be done by clicking the start button and typing “notepad”
at the command prompt.
An untitled notepad will be displayed as shown below.
Step 2
After saving, an internet explorer icon will be displayed with the file name as shown below.
first. html
Double click to execute it. The output will be available in the following manner.
Output
Q15. What is hyperlink? Also, explain about anchor tag with example program.
Answer :
Hyperlink
A hyperlink directs the users from one web page to another HTML page or to any specific part of it or the same webpage.
A hyperlink allows users to navigate between various web pages. It allows users to create hyperlinks using text/images available
on webpage.
Anchor Tag
In HTML, a link is defined using <a> tag. <a> is a anchor tag. The code for creating a link is embedded between the tags
<a> ... </a>.
1. Href
2. Text
This attribute embeds text/image or any other HTML element on web page.
3. Target
This attribute specifies the location to open a link document. Its values are blank, self, parent top and target frame.
4. Base Path
This attribute is used in head region of HTML tag. It provides the base path for the link.
Program
<html>
<head>
</head>
<body>
<a href = “http://www.siapublishers.com/” target = “self”> SIA Publishers and Distributors Pvt Ltd. </a>
</body>
</html>
Q16. What are Basic Text formattings? Write about White-Space property in XHTML.
Answer :
Basic Text Formatting
It is a process of changing the original state of the document such as text color back ground color using textformatting
tags. Every document contains some type text that is represented by using the formatting elements such as <h1>, <h2>, <h3>,
<h4>, <h5>, <h6>, <p>, <br/> and <pre>.
White-space Property
The white-space property is used to control the amount of space between each word. The possible values of white-space
property are as follows,
(i) Pre
The “pre” value preserves the white spaces and does not break the line until the <br> element is used explicitly.
(ii) Nowrap
The “nowrap” value does not preserve the white spaces instead it collapses the sequence of white spaces into a single
space. It does not breaks the line until the <br> element is used explicitly.
(iii) Normal
The “normal” is the default value. It does not preserves the white spaces instead it collapses the sequence of white spaces
into a single space. It breaks the line if it exceeds the available line space of the browser screen.
Example
<html>
<head>
<style type= “text/css”>
p.pre {white-space:pre;}
p.nowrap{white-space:nowrap;}
10 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-1 COMPUTER SCIENCE PAPER-VIII (B)
p.normal{white-space:normal;}
</style>
</head>
<body>
<p class= “pre”>This paragraph demonstrates the use of pre value of the white space property, this paragraph dem-
onstrates the use of pre value of the white space property, this paragraph demonstrates the use of pre value of the white
space property..</p>
<p class= “nowrap”>This paragraph demonstrates the use of nowrap value of the white space property..This paragraph
demonstrates the use of nowrap value of the white space property..This paragraph demonstrates the use of nowrap value
of the white space property..</p>
<p class= “normal”>This paragraph demonstrates the use of normal value of the white space property..This paragraph
demonstrates the use of normal value of the white space property..This paragraph demonstrates the use of normal value
of the white space property..</p>
</body>
</html>
Output
Answer :
Heading tags are used to displays the text in predefined text size and bold face. These tags are used for defining HTML
heading with different levels. Html supports six types of headings.
Where,
<h1> defines the text embedded between these tag with Largest bold font.
<h6> defines the text with smallest bold font lesser than <h5>.
If no value is specified, HTML prints the text containing the (+ve) integer numerals as default case.
3. Definition List
It is a special type of list that lists terms and their definitions. It is created using (define list) <dl> tag. Every term in a
definition list is defined within <dt> (define term) tag and its definition is defined within <dd> (define definition) tag.
Lists can be Nested or Embedded
When one list type is included in other list type then such type of succession is usually referred to as Miscellaneous or
Nested Lists.
Program
An example to illustrate the types of lists is given below,
<html>
<body>
<h2>Ordered List</h2>
<ol>
<li>B.Sc</li>
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 19
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
<li>B.Com</li>
</ol>
<h2>Unordered List</h2>
<ul>
<li>B.Sc</li>
<li>B.Com</li>
</ul>
<h2>Definition List</h2>
<dl>
<dt>B.Sc</dt>
<dd>Bachelor of Science</dd>
<dt>B.com</dt>
<dd>Bachelor of Commerce</dd>
</dl>
<h2>Nested List</h2>
<ol TYPE=”1”>
<li>Course</li>
<ol TYPE=”A”>
<li>B.Sc
<ol TYPE=”i”>
<li>B.Sc(General)</li>
<li>B.Sc(Hons)</li>
</ol>
<li>B.Com
<ol TYPE=”i”>
<li>B.Com(General)</li>
<li>B.Com(Hons)</li>
</ol>
</li>
</ol>
</body>
</html>
Output
(iii) UI Events
UI event attributes are used to link the elements with the event. Keypress or mouse movement are the examples of UI
events.
There are ten common events that are given as follows,
Onclick, Ondoubleclick, Onmouseup, Onmousemove, Onmousedown, Onmouseover, Onmouseout, Onkeypress, Onkey-
down and Onkeyup.
The <body> and <frame set> elements contain onload and onunload events whenever a page is opened or closed.
24 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-1 COMPUTER SCIENCE PAPER-VIII (B)
When the phrase “yahoo” from the site.html page is clicked, the http://www.yahoo.com site appeared in the same window.
In addition to the href attribute, the anchor element can contain the title attribute which describes about the other page the
link navigates to the value of the title attribute is displayed in a tooltip when the user hovers the mouse over the link. This can
be shown with the help of following example,
Example
<html>
<head>
<title> main page</title>
<h1><a href = “http://www.Google.com/” title = “searches the info with google search engine”>Google</a> is a very
popular search engine</h1>
</body>
</html>
Output
When user clicks on the “lists page of the home page, the index.html page gets loaded into the same window by replacing
the home.html page. This can be shown as follows,
For remaining answer refer Unit-I, Page No. 19, Q.No. 22, Topic: Program.
26 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-1 COMPUTER SCIENCE PAPER-VIII (B)
Q28. Explain how the specific parts of a page can be linked.
Answer :
The page can contain links to specific parts of it when the length of page is long or when the page does not fit in the
browser’s window or when the user has to scroll the page to move to the specific location. It is also called internal links.
Some examples of the linking to the specific parts to a page on web pages are as follows,
Long page contains the links “Back of top” at the bottom of the page to navigate.
Page contains the lists of contents that will direct to the relevant part of the page.
Page contains the links in the text to navigate to definitions or to the footnotes.
It is possible by two attributes,
1. Name (or) id attribute
2. Source attribute.
The linking to the specific parts of a page can be achieved by using, source anchors and destination anchors.
(a) Source Anchors
The source anchors specify the links to the specific parts of same page. The href attribute in the source anchor should
contain the value same as the value of id attribute in the destination anchor except that it should be preceeded by a hash sign (#)
(also known as pond sign).
(b) Destination Anchors
The destination anchors contain particular parts in the page that can be linked by source anchor. The destination anchor
contains an attribute, “id”, or name attribute which provides the identification to a particular part of the page. This identification
is used as the value (preceeded by pond sign #) of the href attribute in the source anchor.
Example
<html>
<body>
<a name=“top”>Context</a>
<a href=“#top”>top</a>
</body>
</html>
Output
1.3.1 Adding Images Using the <img> Element, Using Images as Links
Q31. Explain about images and supported attributes in HTML.
Answer : Model Paper-III, Q9(a)
Images (<img>)
This tag adds images to the web pages. They increase the visibility of web pages. These images are stored in computers
by following several strict formats, most common among them are BMP, JPEG, GIF, PMP etc. However ‘.GIF’ are most popular
because of its clarity and support for a wide range of colors. The following is the image tag,
<img src = “pic.gif” alt = “picture”/>
This forms the primary tag to insert images onto the web page.
Supported Attributes
The following are the support attributes of <img> tag,
1. SRC
It specifies the URL (Uniform Resource Locator) i.e., where the image is actually stored in the computer or server. For
example, if the image is stored in the ‘C’ drive, images folder, with name rose.gif, then SRC (Source) can supply URL
address as SCR = “C:\images\rose.gif”. It is mandatory to include SRC attribute within the <IMG> tag.
<img src = “c:/images/rose.gif”/>
30 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-1 COMPUTER SCIENCE PAPER-VIII (B)
2. ALT
It is used to display alternative text if the browser fails to display the required image due to several underlying reasons.
This can be done using ALT attribute.
<img src = “url” Alt = “Text”/>
3. ALIGN
It aligns the given web page. Its values can be “TOP”, “BOTTOM”, “LEFT”, “RIGHT”, “MIDDLE” respectively.
<img src = “url” Align = “Left/Right/Centre”/>
4. BORDER
It specifies the width of the border for the image can be specified. It is usually measured in terms of pixels and its default
value is zero.
<img src = “url” border = “Value in pixels”>
<img src = “image.gif” border = “2”/>
5. HEIGHT/WIDTH
Height and width of the image can be specified using these attributes. Often height and width of an image are measured
in terms of pixels.
<img src = “url” Height = “Value in pixel/Percentage” Width = “Value in Pixel/Percentage”/>
6. HSPACE/VSPACE
The gaps or white spaces between the text and images can be controlled using these attributes
<img src = “url” Hspace = “Value in Pixel” Vspace = “Value in Pixel”/>
<img src = “image.gif” vspace = “10” v space = “12”/>
7. LONGDESC
It usually takes certain URL as argument, where further information related to a given image is stored.
<img src = “url” Width = “Value in Pixel” Height = “Value in Pixel” Longdesc = “file1.html”>
8. NAME
This attribute is used to specify name of the image.
<img src = “url” Name = “name of the image”/>
9. Ismap and Use map
These attributes are used with image maps.
Following is an application supporting insertion of images on the given web pages,
Program
<HTML>
<HEAD>
<TITLE>IMAGES</TITLE>
</HEAD>
<BODY>
<IMG SRC= “IMG1.PNG” ALT= “ERROR” ALIGN= “CENTER” NAME= “IMAGE1” HEIGHT= “200” WIDTH=
“200” HSPACE= “0” VSPACE= “1” LONGDESC= “HTTP://EXAMPLE.COM/DESC#IMAGE1”>
</BODY>
</HTML>
Output
In the above code, the <param> element is used to specify the name as movie with value given as URL. It specifies whther
the player should be in full-screen mode or not. In also allows to play a flash movie from other sites.
38 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-1 COMPUTER SCIENCE PAPER-VIII (B)
Q40. How flash is added to a web page using <object> and <embed> element?
Answer :
<Object> and <Embed> Element
Flash is added to the webpage by using <object> and <embed> elements. A basic flash animation can be added to a web
page by using a different technique called Flash B. When the FIA file exported for creating SWF file. The code created by the
flash adds the SWF file to a web page.
Program
<html>
<head>
<title>Adding a flash movie with the <object> element</title>
</head>
<body>
<p>
<object classid=“clsid:D27CDB6E-AE6D-11cf-96B8-444553540000” width=“300” height=“200” codebabse=“http://
download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab”>
<param name=“movie” value=“flash/flash_sample.swf”>
<param name=“play” value=“true”>
<param name=“loop” value=“false”>
<embed SRC=“flash/flash_sample.swf” WIDTH=“300” HEIGHT=“200” PLAY=“true” LOOP=“false” QUALITY=“best”
MENU=“false” TYPE=“application/x-shockwave-flash” PLUGINSPAGE=“http://www.macromedia.com/shockwave/
download/index.cgi?P1_Prod_Version=ShockwaveFlash”></embed>
</object>
</p>
</body>
</html>
Output
(a) Classid attribute is used for specifying the type of application to be played for a file.
(b) Codebase attribute is used for specifying the plugin or a program at the place where this file is required to be played.
Q41. How flash is added to a web page using SWF object?
Answer :
SWF Object
Flash is added to a web page using SWF object. In this technique, a page is created by using <div> element that holds the
flash video. CSS is used to ensure that <div> element has the width and height same as the SWF file needs <div> element has an
id attribute that specifies uniquely the identity for an element. Images and texts can be used inside <div> element. A javascript
is added to the page that checks for the installed flash player in the browser. When a flash player is installed then the javascript
is used to replace the content of <div> element with SWF file. SWF object can be download from the site http://code.google.
com/p/swfobject/.
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 39
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Program
<html>
<head>
<title>Adding a flash movie with SWF Object</title>
<script type=“text/javascript” src=“swfobject.js”></script>
<script type=“text/javascript”>
swfobject.embedSWF(“flash/flash_sample.swf”, “flash_movie”, “300”, “200”, “8.0.0”);
</script>
</head>
<body>
<div id=“flash_movie”>*Install Flash player</div>
</body>
</html>
Output
Video File Format File Extension MIME Type Default Player on PC Default Player on MAC
Flash video player .swf Application/x-shock- Flash player Flash player
wave flash
AVI .avi video/x-ms video Windows media player Windows media components
are required to be download-
ed by user
MPEG .mpg or .mpeg video/mpeg Windows media player Quick time player
Quicktime movie .mov video/quicktime Plug in should be Quick time player
downloaded by the
user
Windows media .wmv video/x-ms-wmv Windows media player Windows media components
video should be downloaded by
the user
Real media .rm Application/vnd.rn- Real player Real player
realmedia
Example: Adding Videos Using Flash Video
The following are the reasons to describe that the flash video is popularly used to add videos on websites.
(i) Flash player must be installed on computer connected to the internet server or the web and different video formats are
also installed such that users can view FLV files.
(ii) Flash is used for controlling the appearance of the player so that users can create branded players.
(iii) FLV files are compared such that these are smaller than MPEG-1 format with some loss in quality.
(iv) The videos are faster for loading and playing.
(v) Its cost is low for running a website.
A user does not upload the video to anyone of the site then the following things are to be done.
(a) The video has to be converted from one format to the required FLV format.
(b) FLV player is written or downloaded for playing FLV files.
The video can be converted from one formats into the required FLV format in two following ways,
(i) Adobe Software
Adobe software is used to convert video format to FLV provided by flash authoring environment.
(ii) Third-Party Software
Different companies have developed softwares for converting various video formats into FLV files.
Different flash players are available that can be downloaded even though it does have any flash authoring tool as given
below,
(a) OS FLV player
(b) JW FLV player
(c) Flow player
(d) Slideshow pro.
The above players have their own way to specify how to find FLV file.
Program
<html>
<head>
<title>OS FLV Player</title>
<meta http-equiv=“Content-Type” content=“text/html; charset=iso-8859-1”>
<script type=“text/javascript” src=“swfobject.js”></script>
<script type=“text/javascript”>
swfobject.embedSWF(“flash/os_flv_player.swf?movie=video.flv”, “flash_video”, “400”, “340”, “8.0.0”);
</script>
</head>
<body>
<div id=“flash_video”>*Install Flash player</div>
</body>
</html>
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 41
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Output
Video Size
The size of a video must be known when it is downloaded the larger video has more file size. These big files can be
considered as a problem due to following reasons,
(i) If the size of a file is less or small then it is downloaded very quickly. Users loose interest to watch videos which consume
more time for downloading. User’s might pause them for a while.
(ii) If the size of the file is big then it consumes more bandwidth. Some companies that contains websites may charge for
bandwidth.
The long video can be divided into sections for the users to watched.
Q43. How audio is added to web site?
Answer :
Adding Audio to Website
An audio can be added to web site by considering the following things.
(i) File Format
Various types of compression techniques are used to store various types of audio files that effect the quality and size of
file recording.
(ii) Plug in Required for Playing the File
The player is required by the user for playing audio using plug-in.
File Types
The following are the file types used popularly.
(a) MP3
The MP3 is the audio file of the MPEG format. MP3 is popular format for music and songs that are of good quality. Files
can be saved with .mp3 extension and are played in most of the browsers. MIME type for MP3 is given by audio/mpeg.
(b) WAVE
Microsoft and IBM developed the WAVE format for audio files that can be played in most of the browsers. These wave
files can be saved with the .wav file extension. The quality of wave is better compared to MP3. The file size of wave is
more compared to MP3 file. The MIME type for wave file is given by audio/x – wav.
The following are the different formats used on the web that require plug-ins.
(i) Windows Media Audio
It meeds the plug-in of windows media.
(ii) Quicktime
It needs the plug-in of Quicktime.
(iii) Real Audio
It needs the plug-in of Real Media.
42 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-1 COMPUTER SCIENCE PAPER-VIII (B)
Adding Audio using Default Media Players
An extra plugin is not required to download in some browser for playing on MP3 or WAVE files.
An <object> element is used to add the audio file in the page. The type of plug in for playing in audio is determined
automatically by the browser and its value is specified by type attribute.
Program
<html>
<head>
<title>Adding Audio using Default Media Players</title>
</head>
<body>
<h1>Adding Audio using Default Media Players</h1>
<object width=“250” height=“100” type=“audio/mpeg”>
<param name=“src” value=“Sleep Away.mp3” />
<param name=“autoplay” value=“true” />
<param name=“autostart” value=“1” />
<embed src=“Sleep Aay.mp3” width=“250” height=“100” ></embed>
</object>
</body>
</html>
Output
Q45. How the audio or video is played automatically when an page is loaded?
Answer :
There are several techniques that are used to add the audio or video to the web page. Consider the following issues while
playing audio or video automatically when a page is loaded.
(i) Users expect to watch or listen to the file when a page is loaded. Some users will skip the audio or video file when the
page is loaded and some of the users watch it.
(ii) A pause or clear or mute button must be provided for an audio or video so that user can turn off the sound when a page
is loaded.
(iii) The options should be provided to avoid the repetitions of the track i.e. audio or video.
(iv) Some of the audio and video files are charged for the bandwidth of the files if they are hosted on the server. Whenever a
file starts playing automatically when an page is loaded then the user has to pay for watching or listening the file.
Q46. What are the attributes of an <object> element?
Answer :
<Object> Element
HTML uses an object element to insert the multimedia objects directly into the page. This object tag replaces the <img>
tag using the object element is a good approach, because it allows to embed any type of data.
Commonly used HTML tags, devoted for inserting objects on webpages are listed below.
<object classid = “URL” data = “URL” [codebase = “URL] type = “string”
[standby = “string”] height = “n” width = “n” [title = “string”] > ----- < /object>
The attributes of an <object> element are as follows,
1. archive Attributes
Archive attribute is used specifically by Java based applications. Its value is the list of URLS separated by spaces from
the resources.
2. border Attribute
Border attribute creates a border around an object. Its value is provided in the form of pixels.
3. class id Attribute
This attribute is mandatory for every object to specify its URL of the object. If classid specifies only a filename, then
assume that the object is present in the same directory as the HTML page.
Example
class id = “clsid1:02CG36E6 – 9D28 – 2D41 – DE91 – B2398 BCDDB9C”
4. codebase Attribute
This attribute specifies the URL of identify the directory in which the object is present. Codebase attribute is placed in
square brackets which means it is optional. If this attribute is not specified, the full URL of the classid is placed.
Example
codebase = “http://www.yahoo.org/java/”
44 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-1 COMPUTER SCIENCE PAPER-VIII (B)
5. codetype Atrribute
Codetype attribute specifies the MIME type of an application. These are used to skip unsupported media types in the
browsers.
Example
<object data = “details.xls” code type = “application/vnd.ms-excel”>
6. declare Attribute
declare attribute is used for declaring an object that is not instantiated.
Example
declare = “declare”
7. data Attribute
data attribute specifies the URL of the resource to be used by the object.
Example
data = “http://www.yahoo.com/mp4/song.mp4”
8. height and width Attributes
height and width attribute specifies the height and width of an object respectively. The values for these attributes are
provided in pixels or percentages.
9. hspace and vspace Attributes
hspace attributes defines the whitespaces on left side and right side of an object. The vspace attribute defines the whitespaces
on the objects top and bottom.
10. name Attribute
name attribute specifies the name for referring an object in scripts. This attribute is replaced with an id attribute in xhtml.
11. standby Attribute
This attribute displays alternative text while the object is loading from server.
Example
standby = “The page is loading”
12. tabindex Attribute
tabindex attribute specifies the tabindex of an object in a page.
13. usemap Attribute
usemap attribute specifies the object in an image map with hyperlinks. The value used with an object is map file.
Q47. What is <param> element? Explain the attributes of it.
Answer :
<param> element
<param> element is used for passing parameters to an object.
This tag is used whenever an object requires command-line parameters. Syntax of the param tag is
<param name = “string” value = “string” type = “string”
valuetype = [“ref”/”object”/“data”] >
The attributes of an <param> element are as follows,
1. name Attribute
It specifies a name for every parameter.
Example
<param name = “src” value = “show.mov”/>
<param name = “autoplay” value = “true”/>
2. value Attribute
This attribute specifies the value that is to be is passed to the object. The value passed need not be numerical or textual
but can be any of other type.
Example
<param name = “src” value = “onlinesite.com”/>
<param name = “autoplay” value = “true”/>
1.4 TABLES
In HTML, data can also be represented in table format. In this approach a data is usually organized in terms of rows and
columns. The tags and attributes that helps in creating HTML table are as follows,
1. <TABLE>...</TABLE>
Entire code corresponding to a given table should be inscribed within these tags.
Relative Attributes
(i) ALIGN
This attribute allows a user to direct the placement of a given table in the web browser window. Here alignment is usually
performed horizontally by assigning values LEFT/RIGHT/CENTER respectively.
(ii) BACKGROUND
This attribute enhances the visualization of the table by setting an image or other graphics as background. It usually car-
ries a URL path corresponding to the given image or graphics.
(iii) BGCOLOR
This attributes sets the colour of the window in which the table is currently being displayed.
(iv) BORDERCOLOR
This attribute specifies the colour for the given table border.
(v) BORDER
This attribute sets the width of the table border. Hence a value ‘0’ provided to it, displays a table with no border.
(vi) COLS
This attribute specifies the number of columns that the given table should contain.
(vii) HEIGHT
This attribute specifies the height of the given table.
(viii) WIDTH
This attribute specifies the width of a given table.
2. <TR>...</TR>
It corresponds to a single row of a given table. Data supplied within these tags is usually displayed in a particular row of
that table. These tags may have <TH> and <TD> tags within them.
46 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-1 COMPUTER SCIENCE PAPER-VIII (B)
Relative Attributes
(i) ALIGN
It directs the alignment of the text in a given row of a table. It’s value can be LEFT/CENTER/RIGHT.
(ii) BGCOLOR
It is used to set the background colour of the blocks of a table.
(iii) BORDERCOLOR
It sets the border colour for a given row of the table.
(iv) VALIGN
It directs vertical placement of data corresponding to a given row of the table. It can have values as TOP/BOTTOM/
MIDDLE.
3. <TH>...</TH>
This tag is specifically used to set the headings of the available columns. As the data is inserted into the table in row-wise
format, hence <TH> tag usually is followed by <TR> tag. Major difference between <TH> and <TD> tags is that, <TH> makes
the data bold and places it at the centre of the table’s block. On the other hand <TD> inserts data into the block (of table) in
normal font and its positioning depends on its attributes.
Relative Attributes
(i) ALIGN
It directs alignment of data in the header column of the table. Its value can be LEFT/RIGHT/CENTER.
(ii) BGCOLOR
It is used to set the back ground colour for the table headers.
(iii) BORDERCOLOR
It is used to set the border color for the corresponding table headers.
(iv) VALIGN
It directs vertical alignment of data in the table header row.
(v) WIDTH
It sets the width of the table header.
4. <TD>...</TD>
It inserts data into each block of the table. Its supported attributes are ALIGN/BACKGROUND/BGCOLOR/BOR-
DERCOLOR/HEIGHT/SCOPE/VALIGN/WIDTH respectively.
5. <CAPTION>...</CAPTION>
It specifies title to the table. This tag can be placed at the bottom or above the table. Its relative attributes can be ALIGN/
VALIGN respectively.
6. <THEAD>...</THEAD>
It groups certain headers and provides them with single name. This can be accomplished by means of <THEAD> tag. Its
relative attributes are ALIGN/VALIGN/BGCOLOR respectively.
7. <TBODY>...</TBODY>
It is same as <THEAD>. The only difference here is, it groups the specified rows to frame the table body. Its relative at-
tributes are ALIGN/VALIGN/BGCOLOR respectively.
8. <TFOOT>...</TFOOT>
It specifies the table footer by combining its columns. Its relative attributes are ALIGN/ BGCOLOR/VALIGN.
<HTML>
<HEAD>
<BODY>
<H1 align=“center”> Displaying Marks of the student </H1>
<TABLE BORDER = 3 align=“center”>
<TR>
<TH> NAME </TH>
<TH> ROLL NO</TH>
<TH> MARKS </TH>
</TR>
<TR>
<TD> XYZ </TD>
<TD> 12 </TD >
<TD>
<TABLE BORDER = 3 ALIGN = “CENTER” >
<TR>
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 53
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
<TH> TEL </TH>
<TH> HIN </TH>
<TH> ENG </TH>
<TH>MATH </TH>
<TH> SCI </TH>
<TH> SOC</TH>
</TR>
<TR>
<TD> 89 </TD>
<TD> 95 </TD>
<TD> 91 </TD>
<TD> 81 </TD>
<TD> 85 </TD>
<TD> 99 </TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
Q53. How Id, scope and headers attributes are used to make a table more accessible?
Answer :
Id, scope and headers attributes are used for storing the table structure and make it to be more accessible.
When a cell is made as the heading by adding the scope attribute to <th> element, then this will specify to know the
cells under that heading. If the value is given as row then it specifies that the given element/cell is the header for that row. If the
value is given as column then it specifies that given element is the header for that column. If the value is given as rowgroup then
it specifies that cell is the header for that rowgroup. If the value is given as colgroup then it specifies that cell is the header for
colgroup.
Headers attribute is used on <td> element to specify header for respective cells. Its value is the space-separated list of
header cell’s attribute value.
Example
headers = “income p1”
In the above example, the headers have the id attributes with the values income and P1.
Header attribute is used for voice browsers. The record of the table is difficult when a table is read so this is used to keep
the record about the rows and columns of the table and cell to which row and column belongs to.
2. Password-Input Control
For answer refer Unit-I, Page No. 3, Q.No. 2, Topic: The PASSWORD Element.
Example
<html>
<body>
<form action=“” method=“get”>
Login : <input type=“text” name=“login” />
<br>
Password: <input type=“Password” name=“password” />
<input type=“submit” value=“submit” />
</form>
</body>
</html>
Output
<button> Element
Element is used for specifying the text provided between opening and closing tag of <button>.
Example
<!DOCTYPE html>
<html>
<body>
<p>button element</p>
<form>
<input type=“button” value=“Click” onclick=“msg()”>
</form>
<script>
function msg() {
alert(“welcome!”);
}
</script>
</body>
</html>
Output
<option> element
An <option> element with disabled attribute is used for grouping the options.
Example
<html>
<body>
<form action = “” method = “get” name = “Info”>
select any one product:<br/>
<select name = “selectInfor”>
<option disabled = “disabled” value = “ ”> Hardware </option>
<option value = “Desktop”> Desktop computers</option>
<option value = “Laptop”> Laptop computers </option>
<option disabled = “disabled” value = “ ”> Software </option>
<option value = “officesoftware”> Office Software </option>
<option value = “games”> games </option>
</select>
<br/> <input type = “submit” value = “submit”/>
</form>
</body>
</html>
Output
In addition to these controls there is also another control called object control.
Object are embedded in the <object> element within the <form> element of HTML page. For example to use the object
for activating graphical inter action and the value must be stored with its object name.
1.6 FRAMES
<frameset>
The entire code corresponding to frame(s) is usually embedded between <FRAMESET> ... </FRAMESET> tag. This tag
must be included in <HEAD> region of code not in <BODY> region of XHTML code.
Attributes of <frameset>
The <frameset> tag supports the following attributes.
(a) COLS
It displays the total number of columns and the size of frameset. It is measured in pixels.
(b) ROWS
It displays the total number of rows and the size of frameset. It is measured in pixels.
Program
The following code creates a multiple frames on screen. This frames are created using <frameset> tag.
Frame1.HTML
<HTML>
<HEAD>
<TITLE> PROGRAM 1 </TITLE>
<BODY BGCOLOR = “pink”>
<CENTER> <STRONG> <H1> This is program1 </H1> </STRONG> </CENTER>
</BODY>
</HTML>
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 69
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Frame2.HTML
<HTML>
<HEAD>
<TITLE> PROGRAM2</TITLE>
</HEAD>
<BODY BGCOLOR = “Cyan”>
<CENTER> <STRONG> <H1> This is progam2 </H1> </STRONG></CENTER>
</BODY>
</HTML>
Frame3.HTML
<HTML>
<HEAD>
<TITLE> PROGRAM3 </TITLE>
</HEAD>
<BODY BGCOLOR = “Blue”>
<CENTER> <STRONG> <H1> This is program3 </H1> </STRONG> </CENTER>
</BODY>
</HTML>
Mainframe.HTML
<HTML>
<HEAD>
<TITLE> Program to create multiple frames </TITLE>
<FRAMESET ROWS = “25%, 25%, 25%”>
<FRAME SRC = “Frame1.HTML”>
<FRAME SRC = “Frame2.HTML”>
<FRAME SRC = “Frame3.HTML”>
</FRAMESET>
</HEAD>
</HTML>
Output
It is the step to link the above two frames. This can be done as follows,
Consider the code for (links.html).
<html>
<head></head>
<body>
<h1>About Books</h1>
<u1>
<li><a href = “b1.html” target = “main_frame”>Web Technologies</a></li>
<li><a href = “b2.html” target = “main_frame”>J2ME<a></li>
<li><a href = “b3.html” target = “main_frame”>Software Engineering<a></li>
</u1>
</body>
</html>
In the above example program (links.html), when the link “Web Technologies” is clicked, the contents of the page “b1.
html” gets loaded into the target frame named “main_frame”. Similarly when the other links are clicked their associated pages
“b2.html” and “b3.html” gets loaded into the target-frame. This can be shown as follows,
INTERNAL ASSESSMENT
OBJECTIVE TYPE
I. Multiple Choice
1. HTML code should begin with __________ tag and ends with __________ tag. [ ]
8. __________ tag is used to create a link from one page to another page. [ ]
9. The vertical alignment of the data in a table can be done by using __________ attribute. [ ]
(a) 3 (b) 2
10. The process of placing one table inside another table is known as _______.
KEY
I. Multiple Choice
1. <img>
2. <P>
3. bgcolor
4. URL/web address
5. Frame
6. <table> . . . </table>
7. Screen reader
8. <FORM> . . . </FORM>
9. <br/>
Marketed by:
UNIT CASCADING
STYLE SHEETS
2
LEARNING OBJECTIVES
After studying this unit, a student will have thorough knowledge about the following key concepts,
Ø Cascading Style Sheets
Ø More Cascading Style Sheets like Links, List, Tables and Outlines
Ø Page layout, Designing pages, Coding your design and developing for mobile devices.
INTRODUCTION
Cascading Style Sheets (CSS) is one of the most interesting concepts of HTML as it specifies the rules for styling
elements of a web document. It not only extends it features in controlling colors and sizes of fonts, but also
controls spaces between various elements, the color and width of a given line etc. Thus, CSS are used to determine
the style and layout of web pages. There are four different types of column-layouts available for structuring the
pages i.e., two-column layout, three-column layout, four-column layout and six-column layout. In CSS syntax
value should end with semicolon.
Typography refers to an art and technique used in type design which consists of decisions related to type faces,
point size, line length, letter spacing, etc. It means that this keeps a lot of efforts to make the page easy to read,
navigate and to provide the messages clearly. Form is a web page which contains elements like text fields, check
boxes etc. Usually forms are created by inserting <FORM>---</FORM> tags in the HTML code.
PART-A
SHORT QUESTIONS WITH SOLUTIONS
Q1. What is CSS?
Answer : Model Paper-II, Q3
Cascading Style Sheets (CSS), forms one of the most interesting concepts of HTML as it specifies the rules for organiz-
ing elements of a given web document. It not only extends its features in controlling colors and sizes of fonts, but also controls
spaces between various elements, the color and width of a given line etc. Thus, CSS are used to determine the style and layout
of web pages. Generally, style defines the way in which the HTML elements are shown on the web pages. A style can be used in
the following format,
selector{property : value;}
Q2. Write about style rule.
Answer : Model Paper-I, Q3
Style Rule
Style rules specify the appearance of a document. A style rule is composed of two units,
(a) Selector
It represents the elements to which the rule applies. (e.g. h1, h2, p etc.)
(b) Declaration
It represents the properties of an element(i.e., color, font-style, etc) and its value.
Syntax
Selector{Declaration;}
Selector{Property:value;}
Example
h1{Text-align:center;}
Q3. Write a short note on <link> element.
Answer :
The <link> element is an empty element. It is used to link two documents i.e., it is used to link the stylesheets with the
document in which it is present. It not only links a stylesheet but also links an RSS feed that correlate with the web page.
The <link> element has 3 attributes when it is used for associating a stylesheet with the document. They are type, rel and
href. In addition to these core attributes the <link> element can have other attributes they are, charset, dir, href, hreflang, media,
rel, rev, style, target, type.
Q4. List the properties that influence the appearance of the font.
Answer : Model Paper-III, Q3
The properties that directly influence the appearance of the font are as follows,
1. font
2. font-family
3. font-size
4. font-weight
5. font-style
6. font-variant
7. font-stretch
8. font-size-adjust.
80 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
Q5. What is a selector? List the types of selectors Q8. Discuss in brief about tracking.
in CSS.
Answer : Model Paper-I, Q4
Answer : Model Paper-I, Q5
Selector Tracking
Selector is an element to which the style rule is applied. It is also called as letter spacing. It referred to as the
It provides a way to select the element (s) for applying the style space between the letters. In CSS, the letter-spacing property
rules. The elements can be selected in several ways by using is used to control the space between the items on the page. The
the different types of selectors. letter spacing is required when dealing with the headings that
Types of Selectors in CSS is in uppercase letters because reading the headings is little bit
The following are eight different types of selectors in CSS, difficult than reading a sentence.
1. Universal selector Example: h1{letterspacing : 0.1 em;}
2. The Type selector
Q9. Write a short note on,
3. The Class selector
4. The ID selector (i) list-style-position property
5. The child selector (ii) list-style-image property.
6. The descendent selector Answer : Model Paper-II, Q5
7. The general sibling selector
(i) list-style-position Property
8. The adjacent sibling selector
The list-style property specifies the bullet points for
9. The attribute selector.
multiple lines of text by aligning the second line with the start
Q6. Write about vertical-align property. of the first line or aligning it underneath the start of the marker
Answer : Model Paper-II, Q4 (bullets or numbering). This property has 2 values, they are,
Vertical-align Property (a) inside : The second line is aligned underneath the start
This property is used to control the vertical position of of the marker
text or an image.
(b) outside : The second line is aligned with the start of the
Syntax first line.
h1 {vertical-align : value;}
(ii) list-style-image Property
It takes different values. They are,
1. baseline The list-style-image property is used to specify the
2. sub images as the marker rather than a bullet point or number. It
requires the URL of the image as its value.
3. super
4. middle Q10. List the advantages of fixed-width design and
liquid design.
5. top
6. text-top Answer : Model Paper-III, Q5
Selectors Declaration
Property Value
A CSS rule consist of two parts,
1. Selector
2. Declaration.
1. Selector
Selector indicates the elements to be styled. There are three types of selectors namely HTML selector, class selector and
ID selector.
2. Declaration
The declaration indicates the type of the styles that can be applied to an element. The declaration part is again divided
into two parts namely a property and value.
(a) Property: It indicates the property of the attributes of the selected element(s).
(b) Value: Value acts as the specification for the property.
82 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
Example
Property Value
H2 { Color : green ; }
Selector Declaration
A CSS rule can be applied to more than one element. This can be explained with the help of following example.
H1, P, H2 {
color : green;
Rule
font-size : 32 px;
font-family : times new roman ;}
Properties Values
The above example shows a rule which is applied to <H1> <P> and <H2> elements of the document. These elements are
seperated by comma. The rule also consists of property-value pair in the curly braces{ }. The property and value is separated by
a colon(:). Whereas each of the property-value pair separated by semicolon.
An xhtml Code and a CSS Containing Rules
The following is an Xhtml code, to which, the CSS containing different rules are applied. The XHTML code is saved as
“fruits.html”.
The CSS should be saved with the file extension ·css. Here, the stylesheet that used is “style.css”. The stylesheets should
be created in the editors such as windows notepad or text editor on the Mac.
fruits.html
<html>
<body>
<link rel= “stylesheet” type= “text/css” href= “style.css”>
<h1>This is h1 text</h1>
<h2>This is h2 text</h2>
<h3>This is h3 text</h3>
</body>
</html>
style.css
body {
color: #000000;
background-color: #ffffff;
font-family: arial; }
h1 {
background-color: #efefef ;
border-style: solid;
border-width: 2px;
border-color: #999999;}
h2 {
background-color: #cccccc;
font-weight: bold;
padding: 6px;
}
h3 { padding: 6px;}
Output
Q17. List all the main properties available in CSS1 and CSS2.
Answer :
The following table shows all the main properties available in CSS1 and CSS2.
Category Properties
FONT font, font-family, font-size, font-size-adjust, font-stretch, font-style, font-variant,
font-weight.
TEXT color, direction, letter-spacing, text-align, text-decoration, text-indent, text-shadow,
text-transform, unicode-bidi, white-space, word-spacing
BACKGROUND background, background-attachment, background-color, background-image, back
ground-position, background-repeat.
BORDER border, border-style, border-width, border-bottom, border-bottom-color, border-bottom-style,
border-bottom-width, border-color, border-left, border-left-color, border-left-style,
border-left-width, border-right, border-right-color, border-right-style, border-right-width,
border-style, border-top, border-top-color, border-top-style, border-top-width, border-width.
CLASSIFICATION clear, cursor, display, float, position, visibility.
GENERATED content, counter-increment, counter-reset, quotes.
CONTENT
LIST and MARKER list-style, list-style-image, list-style-position, list-style-type, marker-offset.
TABLE border-collapse, border-spacing, caption-side, empty-cells, table-layout.
OUTLINES outline, outline-width, outline-style, outline-color.
POSITIONING bottom, clip, z-index, vertical-align, left, overflow, top, right.
DIMENSIONS height, line-height, Max-height, width, min-width, max-width, min-height.
PADDING padding, padding-bottom, padding-top, padding-right, padding-left.
MARGIN margin, margin-top, margin-bottom, margin-left, margin-right.
2. font-family
The font-family property is used to specify the typeface for the text. Multiple font-family properties can be specified so
that if the first choice of the value is not available in the system, then the browser can select the next font in the list. This can be
shown with the help of following example html code. ( program.html ) which is applied with stylesheet ( s2.css )
Example
<html>
<head>
<title> Font-family Example</title>
</head>
<body>
<p style= “font-family: verdana, arial, sans-serif ;” >first paragraph</p>
</body>
</html>
Output
The comma-separated list of font should end with one of the following generic font names. These generic font names
allow the computer to select its default font type when none of the specified fonts are available in the system. The generic font
names are serif, sans-serif, monospace, cursive, fantasy.
3. font-size
The font-size property is used to specify the size of the font. The value of font-size property can be specified in several
ways. They are,
Absolute xx-small, x-small, Small, medium, large, x-large, xx-large
Relative size smaller, larger
Length px , em, ex, pt, in, cm, pc, mm
Percentage ( in relation to parent element)
2% , 10% , 25% , 50% , 100%.
Program
<html>
<head>
<title> Font-size Example</title>
</head>
<body>
<p style= “font-size: 35px;” >first paragraph</p>
</body>
</html>
Output
5. font-style
The font-style property is used to specify the style of the font. The styles are, normal, italic, oblique etc,. That can be
provided as the values of font-style property.
Example
<html>
<head>
<title> Font-Style Example</title>
</head>
<body>
<p style= “font-style: italic;” >First paragraph</p>
<p style= “font-style: normal;” >Second paragraph</p>
</body>
</html>
Output
6. font-variant
The font-variant property can take two possible values namely normal and small caps. The font-variant property specifies
that the font can be either in normal or small caps. The value small caps of the font-variant allows the appearance of the font
appear like a smaller version of the uppercase letter set. This can be shown with an example.
Example
<html>
<head>
<title>Font-variant Example </title>
</head>
<body>
<p style= “font-variant: normal”> Normal font <span style= “font-variant: small-caps;”>
is represented in small caps </span> in the middle </p>
</body>
</html>
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 91
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Output
7. font-stretch
The font-stretch property is used to control the width of text in a font but not the spaces between them. The values that it
can take is of two types,
1. Relative-normal, wider, narrower
2. Fixed: ultra-condensed, extra-condensed, semi-condensed, semi-expanded, expanded, extra-expanded, ultra-expanded
following is a stylesheet (stretch.css ) which is applied to the html document (program.html).
Program
<html>
<head>
<title> Font-Strech Example</title>
</head>
<body>
<p style= “font-family: verdana, arial, sans-serif; font-stretch: semi-expanded;” >First paragraph</p>
<p style= “font-family: “Arial Black”; font-stretch: condensed;” >Second paragraph</p>
</body>
</html>
Output
8. font-size-adjust
The font-size-adjust attribute is used to modify the font’s aspect value. The font’s aspect value is a ratio. This ratio is
between the height of the lowercase letter ‘x’ in the font and the height of the font.
Example
<html>
<head>
<title> Font-size-adjust Example</title>
</head>
<body>
<p style=“font-family: Times, serif; font-size: 35px;”>SIA</p>
<p style=“font-family: Verdana, sans-serif; font-size: 35px;”>SIA</p>
<p style=“font-family: Times, sans-serif; font-size-adjust: 0.58; font-size: 35px;”>SIA</p>
</body>
</html>
Output
(b) Properties that have other Formatting Influences upon the Font
For answer refer Unit-II, Page No. 93, Q.No. 19.
92 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
The first rule is applied to control the font of all the paragraph elements. The second rule is applied to provide a solid border
of 1px to all the paragraph elements that are children of <div>. The first paragraph is not the child of < div >. Hence, the
second rule is not applicable to it. The third rule is applied to provide the color to last three paragraphs.
9. The Attribute Selector
Attribute selectors select the elements based on the availability of the value of one or more attributes. Attribute selectors
are supported by Firefox and Opera but they are not supported by IE.
There are totally seven attribute selectors out of which four are provided by CSS2 and 3 are extended by CSS3.
(a) Existence Selector
The existence selector matches the elements that have the specified attribute.
Syntax
element [name of attribute]
(or)
[name of attribute]
Example
p [id] it selects all the paragraph elements <p> in the document that have the attribute ‘ id ’. If there is no element name
in the selector, all of the elements are selected by default.
(b) Equality Selector
The equality selector selects the elements depending on their attribute value.
Syntax
element [name attribute = “ value of attribute”]
(or)
[name of attribute = “ value of attribute”]
Example
p [id = “note”] selects all the <p> elements that have the attribute value “note”.
(c) Space Selector
Space selector selects the elements that have same values.
Syntax
element [name of attribute ~ = “ value”]
(or)
[name of attribute ~ = “value”]
Example
p [class ~ = “one”] selector matches with both of the following,
<p class = “one two”> --- </p>
<p class = “underlined one”> --- </p>
(d) Hyphen Selector
The hyphen selector matches an element with attribute value similar to the specified value or starting with the specified
value followed by “-”. The main purpose of this selector is to match the language sub code.
Syntax
element[attribute name | = “value”]
Example
p [long | = “tel”]
matches with,
<p lang = “tel”> - - </p>
<p lang = “tel’ - ANDHRA”> - - </p>
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 103
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
(e) Prefix Selector
The prefix selector matches the elements in which the starting of attribute-value matches with the specified attribute value.
Syntax
element [name of attribute ∧ = “ value of attribute”]
(or)
[name of attribute ∧ = “value of attribute”]
Example
p [id ∧ = “match”] matches
<p id = “matching”> matching -- </p> as well as
<p id = “matchless” > matchless ... </p>
(f) Suffix Selector
The suffix selector matches the elements in which the ending part of attribute-value matches with the specified attribute
value.
Syntax
element [name of attribute $ = “value-of-attribute”]
(or)
[name of attribute $ = “value-of-attribute”]
Example
p [href $ = “.com”] matches
<p href = “http: // www.google.com”> Google </p>
(g) Substring Selector
The substring selector matches the element in which at least one occurrence of the specified attribute value is present.
Syntax
element [attribute-name * = “attribute-value”]
(or)
[attribute-name * = “attribute-value”]
Example
p [id * = “match”] selects all these paragraph elements that have the attribute-value as “match”. The above selector matches
<p id = “Bestmatch Bestmatch > substring </p>.
2.2.5 Lengths
Q22. How lengths can be measured used in CSS?
Answer :
Lengths
In CSS, the lengths can be measured in three ways. They are,
1. Absolute Units
These units are fixed and the different length units in CSS properties are as follows,
(i) pt: It defines the length in points.
(ii) pc: It defines the length in picas.
(iii) in: It defines the length in inches.
(iv) cm: It defines the length in centimeters.
(v) mm: It defines the length in millimeters.
Example
An example to illustrate the absolute units in CSS length properties are as follows,
<html>
<head>
<style>
a {font-size: 4.5pc;}
b {font-size: 25pt;}
c {font-size: 1in;}
d {font-size: 2cm;}
e {font-size: 25mm;}
</style>
</head>
<body>
104 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
<title>Absolute Units</title>
<a>SIA</a><br>
<b>Publishers</b><br>
<c>and</c><br>
<d>Distributors</d><br>
<e>Pvt. Ltd</e>
</body>
</html>
Output
2. Relative Units
The three different types of relative units in CSS properties are as follows,
(i) px: px is known as pixel which is a small part of a digital image. This is used to define the size of the layout.
(ii) em: It is used to define the font-size of the element.
(iii) ex: It is used to define the font-height of the element.
Example
An example to illustrate the Absolute units in CSS Length properties is given below,
<html>
<head>
<style>
a{
font-size: 30px;
}
b{
font-size: 2ex;
}
c{
font-size: 16px;
line-height: 0.5em;
}
</style>
</head>
<body>
<title>Relative Units</title>
<a>SIA Publishers</a>
<b>and</b>
<c>Distributors Pvt Ltd.</c>
</body>
</html>
Output
Border
Padding
Content
2.3.1 Links
Q28. Explain how the links can be styled. Give an example.
Answer :
Styling the Links
The links can be styled by using the following pseudo classes presented in the table,
Pseudo-Class Purpose
link Provides the general style to links
active Provides the styles for links that are currently being activated
visited Provides the styles for links that have already been visited
hover Provides the styles when someone is hovering the link
The following are the properties that can be used with these pseudo classes,
color: provides color to the link
text-decoration: underlines the link
background-color: highlights the link when someone hovers the link.
Example
body {background-color: pink ;}
a{
font-family: arial, Times new Roman;
font-size : 15px; font-weight: bold; }
a: link {
color: green;
text-decoration; none; }
a: visited {
color: blue;
text-decoration : none; }
a: active {
color: yellow;
text-decoration: underline; }
a: link: hover {
background-color: silver;
text-decoration: underline; }
116 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
Q29. Explain in detail about background properties (c) Left: It specifies that images should be positioned
of CSS3 with an example. at left corner
Answer : Model Paper-I, Q10(b) (d) Right: It specifies that images should be positioned
Background Properties at right corner.
Background properties/module of CSS3 are used to (e) Center: It specifies that images should be specified
in add color, images, attachments etc as background to an both horizontal and vertical position.
element. Besides this, it is also used for positioning the size of (f) Length: It specifies the actual length of the pixels.
the background elements. (g) Percentage: It specifies the percentage of the
In CSS3, the color, images etc are specified in the element size of the given document.
background using Background property. 4. background – Size Property
This property is a shorthand property that is used for This property defines the actual size of background
defining each single background properties. The various image.
background properties are as follows,
Syntax
1. background – color
background – size : length | percentage | auto | cover |
2. background – image contain.
3. background – position In the above syntax,
4. background – size
(a) length: It specifies the width and height of the
5. background – repeat background image.
6. background – attachment (b) percentage: It specifies the width and height of
7. background – clip. the background image as percentage.
Syntax (c) auto: It specifies that the background image should
background:color | image | position | size | repeat | have default width and height values.
attachment | clip (d) cover: It specifies that images must be scaled in
1. background – color Property such a way that the background positioning area
This property defines color ‘of’ background : behind the completely covered to the smallest size.
elements in a document. (e) contain: It specifies that images must be
Syntax completely fixed within the display size.
Selector {background – color : color | transparent;} 5. background – repeat Property
In the above syntax, This property defines the directions in which background
images must be displayed.
(a) color: It defines the color of the background.
Syntax
(b) transparent: It specifies that no color must be
added to background so that it should be transparent. background – repeat : repeat | repeat-x | repeat-y |
no-repeat.
2. background – image Property
In the above Syntax, repeat defines the repetitions of
This property helps in adding multiple images as
background image in horizontal and vertical directions,
background to a text element.
repeat-x defines that images must move horizontally,
Syntax repeat-y defines that images must move vertically and
background – image : Url | none no-repeat defines no repetition of background images.
In the above syntax, 6. background – attachment Property
(a) Url: It defines the exact location of the image. This property is used for scrolling the background image
(b) none: It displays empty background image. or for display them at fixed position on the viewing area of the
3. background – position Property given document.
This property specifies the initial position for background Syntax
image. background – attachment : scroll | fixed | local.
Syntax In the above syntax,
background – position: percentage | length | left | (a) fixed: It specifies that the background image must
center | right. be fixed with respect to the viewport.
In the above syntax, (b) scroll: It defines that, the background images must
(a) Bottom: It specifies that images should be be scrolled within the viewport and translated with
positioned vertically its containing element.
(b) Top: It specifies that images should be positioned (c) local: It defines that, the background images must
horizontally be scrolled with respect to the content elements.
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 117
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
7. background – Clip Property
It defines the area of region within which the background image or colon must be extended for an element.
background – Clip : border – box | padding – box | content – box.
In the above syntax,
(a) border – box: It defines that a background color | image can extend its position behind the edge if the is specified
border.
(b) padding – box: It defines that a background can extend its position over inner edge of the given padding border
and does not allow any background below its border.
(c) content – box: It defines that a background can extend its position in content box. It does not allow any background
below the padding area and border.
Example
<html>
<head>
<style>
body {
background-image: url(“download.jpg”);
background-color: lime;
background-position: center;
background-size: auto;
background-repeat: repeat-y;
background-attachment: fixed;
background-clip: padding-box;
}
</style>
</head>
<body>
<h1>The background properties</h1>
<p>Welcome to SIA</p>
</body>
</html>
Output
2.3.2 Lists
Q30. What are the different properties associated with lists? Explain them in detail with an example for each.
Answer :
The different types of properties associated with lists are,
1. list-style-type
2. list-style-position
3. list-style-image
4. list-style
5. marker-offset.
1. list-style-type Property
The list-style-type property is used to control the shape or appearance of the bullet point or number (known as marker)
The following are the standard styles for an unordered list,
(a) none : None
(b) disk (default) : A filled-in circle ex : • • •
(c) circle : An empty circle ex :
(d) square : A filled-in square ex :
The following are the values that can be used for the ordered lists,
(a) decimal : Number
Example: 1, 2, 3, 4, 5
(b) decimal-leading-zero : ‘0’ before the number
Example: 01, 02, 03, 04, 05
(c) lower-alpha : Lowercase alpha numeric characters
Example: a , b , c , d , e
(d) upper-alpha : Uppercase alpha numeric characters
Example: A , B , C , D , E
(e) lower-roman : Lowercase roman numerals
Example: i, ii, iii, iv, v
(f) upper-roman : Uppercase roman numerals
Example: I , II , III , IV , V
Program
lists styletype.html
<html>
<head>
<style type= “text/css”>
li .a {list-style-type : decimal}
li .b {list-style-type : decimal-leading-zero}
li .c {list-style-type : lower-alpha}
li .d {list-style-type : upper-alpha}
li .e {list-style-type : lower-roman}
li .f {list-style-type : upper-roman}
li.h {list-style-type : none}
li.i {list-style-type : disc}
li.j {list-style-type : circle}
li.k {list-style-type : square}
</style>
</head>
<body>
<h1>styles for ordered lists</h1>
2. list-style-position property
The list-style property specifies the bullet points that have multiple lines of text by aligning the second line according to
the beginning of the first line or. This property has 2 values, they are,
(a) inside : The second line is aligned underneath the start of the marker
(b) outside : The second line is aligned with the start of the first line
Example
<html>
<head>
<style type= “text/css”>
ul {list-style-position : inside ;}
ol {list-style-position : outside ;}
</style>
</head>
<body>
<ul>
120 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
<li> This bullet point specifies the effect of ‘inside’ value of the list-style-position property..</li>
</ul>
<ol>
<li> This specifies the effect of ‘outside’ value of the list-style-position property..</li>
</ol>
</body>
</html>
Output
3. list-style-image Property
The list-style-image property specifies images as marker instead of a bullet points or numbers. It requires the URL of the
image as its value.
Example
<html>
<head>
<style type= “text/css”>
ul {list-style-image: url(/pix/printer_icon.gif)}
</style>
</head>
<body>
<h4> Remember to print out info on the following : </h4>
<ul class= “outside”>
<li>list-style-type</li>
<li>list-style-position</li>
<li>list-style-image</li>
</ul>
</body>
</html>
Output
5. marker-offset Property
The marker-offset property is used to specify the number of spaces between the marker and the text. The length is provided
as value for it. It is not supported by IE2 and firefox2.
Example: li {marker-offset-3em ;}
2.3.3 Tables
Q31. What are the specific properties associated with tables? Explain them in detail with an example for
each.
Answer :
The different <table> specific properties are as follows,
1. border-collapse
2. border-spacing
3. caption-side
4. empty-cells
5. table-layout.
122 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
1. border-collapse
The border-collapse property is used for the two purposes,
(a) It allows the border to control the appearance of the adjacent borders. The border is made to collapse with the borders
of its adjacent cells.
(b) It allows the cells border to maintain their own style. The border is separated from the borders of its adjacent cells.
The border-collapse property can take two values they are collapse and separate. The value collapse maintains the first
purpose of the border-collapse property whereas the value ‘separate’ maintains the second purpose of the border-collapse property.
Example
<html>
<head>
<style type= “text/css”>
table.table1 {border-collapse : separate ;}
table.table2 {border-collapse : collapse ;}
td.a {border-style : solid ; border-width : 4px ; border-color : green ; padding : 15px ;}
td. b {border-style-dotted ; border-width : 4px ; border-color : red ; padding : 15px ; )
</style>
</head>
<body>
<h2>separate</h2>
<table class= “table1”>
<tr>
<td class= “a”>cell1</td>
<td class= “b”>cell2</td>
<td class= “a”>cell3</td>
</tr>
<tr>
<td class= “b”>cell4</td>
<td class= “a”>cell5</td>
<td class= “b”>cell6</td>
</tr>
<tr>
<td class= “a”>cell7<td>
<td class= “b”>cell8<td>
<td class= “a”>cell9<td>
</tr>
</table>
<h2>collapse</h2>
<table class= “table2”>
</tr>
<td class= “a”>cell a</td>
<td class= “b”>cell b</td>
<td class= “a”>cell c</td>
</tr>
<tr>
<td class= “b”>cell d</td>
<td class= “a”>cell e</td>
<td class= “b”>cell f</td>
</tr>
<tr>
<td class= “a”>cell g</td>
<td class= “b”>cell h</td>
<td class= “a”>cell i</td>
</tr>
</table>
</body>
</html>
2. border-spacing
The border-spacing property is used to specify the distance between any two cells in the table. The value of it can be one
or more units of length. If it accepts one value then it can be applied for both the vertical and horizontal distance. If it accepts
two values, the first value is specified for the horizontal distance and the second value is specified for the vertical distance. It is
not supported by IE7.
Example
<html>
<head>
<style type= “text /css”>
table {width : 350px ; border-collapse : separate ;}
td {font-size : 17px ; text-align : center ; border-width : 4px ; border-color : green ; border-style : solid ; border-spacing
: 3pxpx ; 3px}
</style>
</head>
<body>
<table>
<tr>
<th>Fruits</th>
<th>color</th>
</tr>
<tr>
<td>Apple</td>
<td>green</td>
</tr>
<tr>
<td>Banana</td>
<td>yellow</td>
</tr>
<table>
</body>
</html>
124 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
Output
3. caption-side
The caption-side property is used to specify the direction of the caption with respect to the table. The position of the cap-
tion can be specified by using four values they are top, right, bottom, left.
(i) top : The position of the caption will be at the top of the table.
(ii) right : The position of the caption will be at the right of the table.
(iii) bottom : The position of the caption will be at the bottom of the table.
(iv) left : The position of the caption will be at the left of the table.
Example
<html>
<head>
<style type= “text /css”>
caption {caption-side : top ; font-size : 20px ;}
table {border-style : solid ;}
th, td {font-size : 20px ; text-align : center ;}
table {width : 350px}
</style>
</head>
<body>
<table>
<caption>vegetable colours</caption>
<tr>
<th>vegetable</th>
<th>color</th>
</tr>
<tr>
<td>carrot</td>
<td>orange</td>
</tr>
<tr>
<td>tomato</td>
<td>red</td>
</tr>
<tr>
<td>beans</td>
<td>green</td>
</tr>
</table>
</body>
</html>
Output
5. table-layout
The table-layout property allows the user to specify the table layout. It can take three values, namely fixed, auto and
inherit. This property can only be used when the table is too large and requires long time to load.
(a) fixed
The value ‘fixed’ allows the browser to calculate the layout of the table by considering the fixed width specified for a cell
in the column and by calculating the width of other cells in that column.
(b) auto
The value ‘auto’ allows the browser to calculate the layout of the table by considering each cell and calculating the size
based on the settings for all cells. This value is used when the exact size of each column is not known.
(c) inherit
The value ‘inherit’ allows the browser to inherit the properties for a table from its parent table. It is used in case of nested
tables.
126 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
Example
<html>
<head>
<style>
table {
border-collapse: collapse;
border:1px solid black;
}
th,td {
border: 1px solid black;
}
table.one {
table-layout: auto;
width: 180px;
}
table.two {
table-layout: fixed;
width: 180px;
}
</style>
</head>
<body>
<title>The table-layout property</title>
<h2>table-layout:auto Property</h2>
<table class=“one”>
<tr>
<th>Name</th>
<th>Date of joining</th>
<th>Salary</th>
</tr>
<tr>
<td>Nikhil</td>
<td>12-06-2017</td>
<td>15000</td>
</tr>
<tr>
<td>Vara</td>
<td>22-01-2013</td>
<td>25000</td>
</tr>
<tr>
<td>Veera</td>
<td>31-10-2018</td>
<td>10000</td>
</tr>
</table>
<h2>table-layout:fixed Property</h2>
<table class=“two”>
<tr>
<th>Name</th>
<th>Date of Joining</th>
<th>Salary</th>
</tr>
<tr>
<td>Nikhil</td>
<td>12-06-2017</td>
<td>15000</td>
</tr>
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 127
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
<tr>
<td>Vara</td>
<td>22-01-2013</td>
<td>25000</td>
</tr>
<tr>
<td>Veera</td>
<td>31-10-2018</td>
<td>10000</td>
</tr>
</table>
</body>
</html>
Output
2.3.4 Outlines
Q32. What are the different outline properties in CSS? Give an example.
Answer :
Outline Properties
The outline properties are used to highlight certain parts of the page without affecting the page content. The different
outline- properties in CSS are as follows,
1. The outline-width property
2. The outline-style property
3. The outline-color property
4. The outline property
1. The outline-width Property
This property is used to set the width of the outline that is to be added to the box.
Example
a{outline-width: thick;}
2. The outline-style Property
This property is used to set the style of the outline that is to be added to the box. Dashed, dotted, solid are the different
styles of the outline.
Example
a {outline-style: solid;}
(or)
a {outline-style: dashed;}
(or)
a {outline-style: dotted;}
128 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
3. The outline-color Property
This property is used to set the color of the outline that is to be added to the box. It accepts the color value either by color
name, or RGB value, or hex color value.
Example
a { outline-color: blue; }
(or)
a { outline-color: #0000FF ; }
(or)
a { outline-color: rgb(0,0,255); }
4. The outline Property
This property is used to set the three properties at a time to the outline.
Example
a {outline: 5px dotted pink; }
A simple html program with all the outline properties is as follows,
outline-properties.html
<html>
<head>
<style>
p.a
{
border: 1px solid black;
outline-width: thick;
outline-style: solid;
outline-color: blue;
}
</style>
</head>
<body>
<title>Outline-Properties</title>
<p class=“a”>A solid outline in Blue color</p>
</body>
</html>
Output
3. Absolute Positioning
Absolute positioning scheme is used to fix the position of an element. To do this, set the position property of the element
to absolute.
Example
ex9.css
body {
color:#000000;
background-color:#ffffff;
136 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
font-family:arial, verdana, sans-serif;
font-size:12px;}
div.page {
position:absolute;
left:50px;
top: 100px;
padding:20px;
border-style:solid; border-width:2px; border-color:#000000;}
absolute-positioning.html
<html>
<head>
<title>Absolute Positioning</title>
<link rel= “stylesheet” type= “text/css” href= “ex9.css” />
</head>
<body>
<div class= “page”><p>Here is paragraph <b>1</b>. This will be at the top of the page.</p>
<p class= “two”>Here is paragraph <b>2</b>. This will be in the middle of the page.</p>
<p>Here is paragraph <b>3</b>. This will be at the bottom of the page.</p>
</div>
</body>
</html>
Output
Q43. Give the advantages and disadvantages of fixed width design and liquid design.
Answer :
Advantages of Fixed-width Design
1. The line length of the text can be controlled without bothering about the size of user’s window.
2. The page size remains the same.
3. The designer has full control on the position and appearance of items on the page.
4. The width and position of elements can be controlled exactly by pixel values.
Disadvantages of Fixed-width Design
1. The text may not fit in the space allotted to it, if its size is set to large.
2. The web page might look smaller if browsed at higher resolution than it is designed for and page elements will not be
clear enough to read.
3. Page must be in the middle of the window leaving gaps around it sometimes.
4. The container elements which are used to control the page layout might remain at the end of the code. By this the page
becomes cluttered and can easily break.
5. This design is applicable only on the devices whose size and screen resolution is same as for desktop computers.
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 141
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Advantages of Liquid Design
1. The page expands and fills the browser window without leaving any gaps around it.
2. The users are allowed to set font size lager than intended because page layout is stretchable.
3. The page can even fit in a small size window, there is no need for scrolling it.
Disadvantages of Liquid Design
1. The width of the sections of the page need to be controlled, otherwise the design looks different or might display gaps
around elements or elements may squash together.
2. If the window is very wide, then the lines of text become long making it hard to read. And if the window is too narrow,
then each line might have a word or two.
The following figure with the set of super imposed lines indicates how the site is designed using the grid system.
Drawing a grid on the basis of golden ratio becomes complicated. Therefore, use some other alternative method such as
rule of thirds to draw grids i.e., divide the page into 3*3 equal parts and figure out the intersecting points. Suppose the width of a
web page is 960 pixels then it is divided into three columns each of 320 pixels. And also vertical lines should be drawn for each
320 pixels width. This will create grid boxes which will be further divided into thirds.
There should be some space between the columns in order to avoid the jumping of text or image from one column to
another column. The space is called as “Gutter”.
Consider a page of width 960 pixels. Make the page as a 12 column grid which is as shown in the below figure,
In the above figure, each column is of width 80 pixels and every column is separated by 20 pixels.
A grid is used to create two columns of equal size in layout or single column layout that is as shown in the below figure,
Designers might even make use of same units of measurement for vertical spaces to produce vertical lines. But this is not
possible, so vertical measurements are used to divide by the width of single column. A 12 column grid in the form of vertical
lines set with same distance is shown as follows,
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 143
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Links to
other
pages of
the site
Product A and
description price
Product B and
description price
Figure
The page need to be action oriented if they are display- Provide the description for the text links then only user
ing product information and also allow the customer to will get to know what will be the content when the link
locate or select the item, to find required information is opened.
about a product and also buy lit. 2.4.4 Coding Your Design
Content pages should avoid using unrelated text and
Q52. What are the different properties that are used
images which make users distracted from knowing the
to position the items on the page. Discuss in
actual purpose of the page.
detail about IE Box Model Bug.
Q50. What influence does images have on design?
Answer :
Answer :
Properties that used for Position the Items on the Page
The images that are incorporated in sites have a strong
The different properties that are used to position the
influence on the visitors. Use of good images, logos and graph-
items on the page are as follows,
ics in the sites attract most of the visitors towards it. If the front
page has a poor photo then the users does to visit that site how 1. The XHTML <div> Property
much ever good the content might be.
It is used to group the items of the XHTML pages to
The photographs that are shot especially for that com- chunks or blocks.
pany which represent the product or company or life-style of
2. The CSS margin Property
company are featured in the site mostly. The quality of the
images depend upon the budget for the site. If clients already It is used to separate the blocks.
have the photos then they are used or else if the hired clients
budget is large then photographers are being hired in order to 3. The CSS width Property
take appropriate shots. Most of the multinational companies It is used to set the width of the box.
and popular brands are hiring photographers to take impressive
photos and their sites contain impressive graphics. 4. The CSS float Property
There are number of stock photo sites from which the It is used to align the <div> elements to the left or right
appropriate images can be obtained but they need to be paid. of the page.
In the above example, two <div> items are used. First one is the id attribute with the frame value (width of the grid) and
the second one is the id attribute with page value.
Q54. Explain the multi-column layouts with examples.
Answer :
A layout that contains multiple layouts is called multi-column layout. Examples of it are two column layout, four column
layout etc.
Two-column Layout
A two-column layout contains two columns with multiple rows in a page. It contains heading that spans for both the
columns. It contains a navigation bar below the header and footer at the bottom of the page.
Example
ex4.css
body {
margin:0px;
background-color:lime;
font-family:arial, verdana, sans-serif;
text-align:center;}
#frame{
margin-left:auto;
margin-right:auto;
text-align:left;
width:960px;
background-image:url(“image.jpg”);
background-repeat:repeat-y;}
#page {
margin:0px 10px 10px 10px;}
#header {
background-color:yellow;
padding:10px;
height:120px;}
#navigation {
background-color:orange;
padding:10px;
height:40px;}
#footer {
background-color:pink;
Four-column Layout
A four-column layout contains four columns with multiple rows in each of them. It contains heading that might span for
all the four columns. It contains a navigation bar below the header and footer at the bottom of the page.
Example
ex5.css
body {
margin:0px;
background-color:lime;
font-family:arial, verdana, sans-serif;}
#frame {
margin-left:auto;
margin-right:auto;
width:960px;
background-image:url(“image.jpg”);
background-repeat:repeat-y;}
#page {
margin:0px 10px 10px 10px;}
#header {
background-color:yellow;
padding:10px;
height:120px;}
#navigation {
background-color:orange;
padding:10px;
height:40px;}
#footer {
background-color:pink;
padding:10px;
height:40px;
clear:both;
border-top:20px solid #ffffff;}
/* 4 columns */
150 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
.column1of4, .column2of4, .column3of4, .column4of4 {
float:left;
width:200px;
background-color:#cccccc;
padding:10px;
margin-top:20px;
height:175px;}
.columns1and2of4 {
float:left;
width:440px;
background-color:#cccccc;
padding:10px;
margin-top:20px;
height:175px;}
.columns2and3and4of4 {
float:left;
width:680px;
background-color:#cccccc;
padding:10px;
margin-top:20px;
height:175px;}
.column1of4, .column2of4, .column3of4, .columns1and2of4 {
margin-right:20px;}
four-column.html
<html>
<head>
<title>4-column Layout Example</title>
<link rel= “stylesheet” type= “text/css” href= “ex5.css” />
</head>
<body>
<div id=“frame”>
<div id= “page”>
<div id= “header”>Header</div>
<div id= “navigation”>Navigation</div>
<div class= “column1of4”>column 1 of 4</div>
<div class= “column2of4”>column 2 of 4</div>
<div class= “column3of4”>column 3 of 4</div>
<div class= “column4of4”>column 4 of 4</div>
<div class= “columns1and2of4”>columns 1 and 2 of 4</div>
<div class= “column3of4”>column 3 of 4</div>
<div class= “column4of4”>column 4 of 4</div>
<div class= “column1of4”>column 1 of 4</div>
<div class= “columns2and3and4of4”>columns 2 and 3 and 4 of 4</div>
<div id= “footer”>Footer</div>
</div>
</div>
</body>
</html>
Answer :
Most of the users think that the use of internet on mobile phones is not much relevant to them or their company. But, by
considering the following observations user may change their decisions.
The success rate of certain high profile mobile devices such as iPhone and Blackberry.
The statistics that represent number of users who are using the web or internet on mobile devices.
The British government has conducted a survey in 2009. It says that the 11% of the UK web users are using web through
mobiles. This is equal to the 1/5th of the web users over the world.
People use their mobile phone while moving from one place to another when they are in hurry. And they can be used
with one hand. Using mobile, the user can get the same result as the personal computer. One more advantage is mobile phones
are portable devices. Mobile phones are also used to perform some specific things such as finding nearby places, weather report,
latest news regarding sports, politics and etc.
The relationship between the user and the mobile phones is personal. Most of the users have their own mobile phones
rather than having a personal computer (Desktop computer). Desktop computer is shared between the friends and family where
the mobile phones are treated as personal. A user can carry mobiles phones everywhere 24 by 7.
152 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
3. Capabilities: How do features of mobiles compare with desktop PCs?
The comparison between the features of mobiles and desktop PCs are as follows,
Feature Mobile Phones Desktop PCs
Location Specific Services It is provided with the GPS or triangulation The Desktop PCs don’t have any GPS system.
to specify the user location.
Built-in Camera They are provided with Built-in camera. These are not provided with Built-in cameras.
User can connect the web cameras whenever
required.
Built-in Payment System The mobile phones are provided with the These PCs also have the payment system but
payment system where a user can have deb- most of the users prefer mobile phone payment
it/credit card details. systems.
Voice Data Mobile phones are integrated with voice Desktop PCs allows phone calls through sky-
data. They allow phone calls. pe.
Other Features Mobile phones are provided with the servic- PCs doesn’t provided with the SMS & MMS
es like SMS, MMS and etc. services.
Contrast
The above figure explains the space between the large The contrast of a page should be good between the items
elements (Macro white space). and the background to provide better presentation to the users
Consider the below figure that shows a page with some even when they have bad quality monitors or light focus on
items that are separated with different spaces. their screens.
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 157
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Even if the contrast is high then the user may suffer. 1. Menus Must Focus on What the Users Want to
Therefore provide enough contrast. For instance consider the Achieves
below figure, For all the sites especially commercial sites, the main
priority of the menus must be to satisfy the users satisfy the fol-
lowing,
Provide the required information for users in the
size.
Provide this information in clear and concise man-
ner.
Priorities the item for which the site is mostly
visited.
2. Menus must be Separated from the Content
A menu must be easily identifiable for the users to navi-
gate the site. This can be achieved by the following techniques,
By using different font size for the menu compared
to main content
By adding extra space around menu
By placing the menu is a box with colored back-
Notice that the black color text on the white background ground or separating a menu from the main content
color is not much easier to the user to read but the white color text with a time.
on the black color background is good enough. In this examples, By using images for the menus. But large images
the contrast can be reduced by providing a dark gray color text slow down the loading of a site.
on a white background rather than using black on white. In the 3. Icons Used as Menus must be Understandable and
same way, light gray on a black background color is easy to read. Add a Link also
In case if you are using an image as background then Many web sites use images called as icons for links
choose the low contrast image to read the page easily and clearly. as menus. For example, a magnifying glass indicates search
features. Such type of images must be understandable if not
2.5.2 Navigation the users may not use them. Mostly the icons such as a house
for home page, envelope for email address, a question for help
Q59. What is the need of navigation? List the meth-
files are used. It would be better if a link is provided in words
ods of navigation.
with the icons that are less common.
Answer :
Although site is planned in a perfect manner, the users 4. Menus must be Quickly and Easily Readable
will use the site in their own way. For example, a site contains The visitors usually do not read the pages while brows-
various pages that can be visited from its home page, but the ing, rather they scan them. So, the menus should be distinct and
visitors might visit from some other page that is linked to other clear from the main part of the page so that users can easily
site links. The users visit according their needs. So, site must be scan and register the navigation.
designed in such a way that visitors find the required informa- The images used on a menu must be large enough and
tion easily and quickly. There are three methods of navigation the text must contrast with its background with enough size.
using which the users navigate the site. Their links also must be short and concise. For example, a link
1. Users can navigate by using the menu that is provided. “Home” is easily readable and understandable.
2. Users can navigate by browsing through the links that 5. Menu Items must be Logically Grouped
are provided in between of text or any other parts of When many pages are available then use submenus. The
page rather than the menu. menu items must be carefully grouped so that visitors can eas-
3. Users can also navigate by searching for relevant items ily understand where to look for the required information with
of information. searching through several categories. The submenus must be
Q60. How menus helps the users to navigate your easily distinguishable from the main menu and should be clear
site? Explain. which items belong to which section. The submenus mostly
Answer : appear in different color background, smaller font, an idented
A keypart of any website that features more than one page position, or an alternate color from the main menu.
is called a menu. A menu represents various sections of a site. It 6. Menu Items must be Easy to be Selected
allows the users to get where they want to go on site. A site can A menu item should be in such a way that a user can
contain more than one menu. It can have a primary navigation in easily select it. A menu item which is small or has less space
one menu and secondary navigation in a submenu or in a separate between menu items or moving seems harder to select. And the
menu. The guiding rules for the menus are as follows, menu items which are large are easier to select.
158 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
Make sure while creating the menus that they work on Q62. How a user can navigate your site using search
all the main browsers and avoid complex code in menus. The feature? Explain.
experimental types of menus that move and slide between the
Answer :
items as the user moves the mouse over an item need fine control
of a pointing device such menus look great on experimental A search feature allows the user to find the information
site. that they need from our site by looking a keyword relating to
7. Menus must Load Quickly the information. Hence, user can also navigate the site using
Every visitor to the site may not have a internet connec- the search feature. This features decreases the difficulty of the
tion. So, menus must load quickly an any connection. Although users in finding what they came for to the site and saves them
speed of connection improves, a menu should load within a from learning the navigation scheme.
couple of seconds. If it takes longer than 8 seconds to load then Search Feature makes the Site more Usable
users think that page is not loading or browser is frozen. The
Search feature is important as our site grows. This feature
users might reload the page or go to another page.
can be implemented in many ways. User can add simple features
Loading speed is very important for the menus that con-
in some ways and some methods need advanced programming
tain flash or graphics. The loading time doubles when the user
experience.
want to change the image or appear highlighted when mouse
is rolled over an image. In large commercial sites whose content is stored in
8. Menus must be Consistent Across a Site the database, user can use programming commands such as
A site with many pages requires a menu with many queries to ask for the required information. User can even use
navigation items. When submenus are introduced the navigation an indexing application to index the site using which the search
becomes difficult and also varies from page to page. But it is feature becomes available.
important to maintain the primary navigation consistent across The sites which doesn’t use databases or indexing tools
all the pages. can simply added a searched feature by creating a search box
The submenus in each section must be in the same posi- when the users enter their queries in the search box, they will
tion on every page and also look similarly to help the users to be sent to the server of the company which offers the search
know the exact place to navigate. service and then the server will return the answers to the user.
Q61. How a user can navigate your site using links? Google is one of the best known company which offers this
Explain. service for free.
Answer : Adding Google Search to our Site
The web pages not only provide menus for the users to Google is most widely used search engine on the internet
navigate the site, they also contain hyper links in the text which at present. It offers a very powerful and flexible service and
is in the body of the document. The users can also navigate us- user can use this service to provide the search feature on the
ing these links. These links are not the part of main menu. Two site. User have to do this by registering for it while writing the
different types of links are as follows, code for the site. The instructions, setup for it are very simple
1. Text links on the site and service is also free.
2. Image links.
1. Text Links 2.5.3 Tables
The text links will be represented in blue color with a
underline by default. It is suggested by some of the ex- Q63. Explain in detail about tables.
perts that, it would be easy for the users to identify the Answer :
links if they are left to their default appearance. Using a
The different techniques that allows the user to read the
different color from the main menu for the links makes
tables quickly are as follows,
it easy to tell which text makes up the link.
In addition to this one can also change the appearance 1. Padding
of the link as the user hovers the link, by changing their 2. Headings
color, gaining a background color or the links getting
underlined. Changing the shade of the links which the 3. Shading rows.
users have already visited reminds them where they have 1. Padding
been earlier.
The padding is used to define the space between each
2. Image Links item and the border.
Images can used as links in menus, advertisements, photo,
graphical icons etc. Two attributes need to be used when Example
an image is used as link. One attribute is ‘alt’ which tells th, td{
the description of the image and another is the title of the
padding: 10px;
link. In case if not using CSS, user need to add the border
attribute for the images that are used as links. }
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 159
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Program
<html>
<head>
<style>
table, td, th {
border: 1px solid #ddd;
text-align: left;
}
table {
border-collapse: collapse;
width: 100%;
}
</style>
</head>
<body>
<table>
<tr>
<th> Name </th>
<th> Rollno </th>
<th> Course </th>
<th> Subject</th>
</tr>
<tr class = “even”>
<td> Ashok </td>
<td> 120 </td>
<td> BTECH </td>
<td> IT </td>
</tr>
<tr class = “odd”>
<td> Ujmala </td>
<td> 121 </td>
<td> BTECH </td>
<td> IT </td>
</tr>
</table>
</body>
</html>
Output
2.5.4 Forms
Q64. What is a form? Discuss the steps to be followed before designing the form.
Answer :
Form
Form is a webpage which contains various elements like text fields, checkboxes, buttons etc. Online forms can be used
for different purposes.
Example
Online registration, order entry, subscription etc.
Steps to be followed before Designing the Form
Before designing the form the designer should follow the below steps,
1. List the Required Information
List all the requirements that you want to provide in the form. For a registration form the following information is required,
(a) Login information
(b) User name
(c) User address
(d) Contact details.
The above listing include the exact information as,
(a) Login Information
It includes user id and password
(b) User Name
It includes First name and last name
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 163
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
(c) User Address
It includes colony, city, state, pin code
(d) Contact Details
It includes mobile number, e-mail id, address
2. Group the Related Information
After listing the required information check for the related information and group them accordingly. In the above example,
the related information can be grouped like the following,
Name and E-mail id
Login information
Other details
Q65. Explain the process of designing a form.
Answer :
Design the form when you know all the form controls that are to be added to the page by grouping them together and
labeling them accordingly.
Selecting the Right Type of Form Control
After estimating the approximate length and layout of the form. Decide the different form controls to be added to the page.
The user can enter the text using three types of form controls. They are,
Using <input> element whose type attribute has text as its value (when the text is one line).
Using <textarea> element (when the text is more than one line).
Using <input> element whose type attribute has password as its value (when the text is sensitive).
The user can choose one of the following controls when he/she wants to choose one option from all,
Radio buttons when only one option is required to be selected from multiple.
Check boxes or multiple checkbox when multiple options are required to be selected from multiple.
Note that while declaring the form controls, the names of the controls should be related to the information provided. The
different control names to describe the type of form controls use the following,
1. txtName for text areas and text boxes
2. chkName for checkboxes
3. selName for select boxes
4. radName for radio buttons.
1. Textboxes
Textbox control adds textboxes onto the form present on editor window. A textbox that allows the user to add text in the
area present in textbox. A text box control is added to order form. That is, a text box control basically accepts input from users. If
the text is small then you can use one line textbox or else use multi-line text area. For example, users are asked for their favorite
subject and why.
2. Radio Buttons and Check Boxes
Radio button control adds radio button onto a form. A radio button can be used for selecting single options from a set of
options.
Check box control adds check boxes to a form. A check box allows a user to select options by checking or unchecking it.
Dropdown list control adds list of data as drop down list. A drop down list is used for making a single selection from the
list.
164 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
Grouping Controls
Grouping of various controls can be done by using the <fieldset> element or by splitting the form into several pages.
Using <fieldset> Elements
It is used to group all the related elements in a form.
Example
<head>
<title>Login</title>
<link rel= “stylesheet” type= “text/css” href= “s1.css” />
</head>
<body>
<form name= “Example” action= “ ” method= “post”>
<fieldset>
<legend>Login info</legend>
User name: <input type= “text” size= “15” name= “txtUserId” /><br />
Password: <input type= “password” size= “15” name= “txtPassword” /><br />
Confirm password: <input type= “password” size= “15” name= “txtPasswordConfirm” /><br />
<input type= “submit” value= “Login” />
</fieldset>
</form>
</body>
</html>
Output
Layout of Forms
The layout of a form will attract the user to use the pages. Some of the issues concerned with the layout of forms are as
follows,
Labeling Controls
The labeling of the form controls should be clear and user should quickly understand what actually it is. The two different
types of labels are as given below,
Explicit labels: These labels use <label> element.
Implicit labels: These labels use normal text and markup text to the control.
Example
The simple example to illustrate the explicit labels is as follows,
<?xml version= “1.0” ?> <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitionalt//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns= “http://www.w3.org/1999/xhtml” lang= “en” xml:lang= “en”>
<head>
<title>Implicit labels</title>
<link rel= “stylesheet” type= “text/css” href= “s3.css” />
</head>
<body>
<form name= “Example” action= “ ” method= “post”>
<fieldset>
<legend>Sign Up</legend>
<label for= “firstName”>First name: </label>
<div class= “control”>
<input type= “text” name= “txtFirstName” size= “20” id= “firstName” />
</div>
<label for= “lastName”>Last name: </label>
<div class= “control”>
<input type= “text” name= “txtLastName” size= “20” id= “lastName” />
166 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-2 COMPUTER SCIENCE PAPER-VIII (B)
</div>
<label for= “email”>E-mail address: </label>
<div class= “control”>
<input type= “text” name= “txtEmail” size= “20” id= “email” />
</div>
<label for= “phone”>Phone: </label>
<div class= “control”>
<input type= “text” name= “txtPhone” size= “20” id= “phone” />
</div>
<input type= “submit” value= “Sign Up” />
</fieldset>
</form> </body>
</html>
Output
Suppose, basic form is the main part of a page then the basic form contains many form controls. Login page, theasures.
com pages are the examples of large form inputs.
INTERNAL ASSESSMENT
OBJECTIVE TYPE
I. Multiple Choice
1. CSS stands for ____________. [ ]
3. ____________ property places the text in the browser’s window according to the specified value. [ ]
4. ____________ value preserves the white spaces and does not break the line until <br> element is used. [ ]
5. The ____________ pseudo class applies the styles to the first line of an element. [ ]
6. ____________ selector applies the style to an element that is the next sibling of another. [ ]
9. The web page whose dimensions are not fixed is called as ____________. [ ]
10. ____________ rule is used to import a style sheet into the present style sheet. [ ]
3. The _________ is used to control the amount of space between each word.
4. The _________ selector can be used to apply a rule to all the elements of a document.
6. The web page whose dimensions are not fixed is called as _________.
8. _________ is used to define the space between each item and the border.
9. _________ is the process of collecting independent units of information and grouping them together to form a large
unit.
KEY
I. Multiple Choice
1. (c) 2. (c) 3. (a) 4. (b) 5. (a)
1. Style sheet
2. href
3. White-space property
4. Universal
5. Composition
6. Liquid design
7. Form
8. Padding
9. Chunking
10. Leading
Answer :
Style sheet is a document written in any styling language. It consists of style information which can be prepared using
the specific formatted style rules.
Answer :
Content property is used to specify the type of content that should be added to the document. The various values that add
different type of content to the document are as follows,
A String
A Counter
A URL
attr(x)
open-quote
close-quote
no-open-quote
no-close-quote.
Answer :
1. px
2. em
3. ex.
Answer :
Typography refers to an art and technique used in type design which comprises of decisions relating to type faces, point
size, line length, letter spacing, etc.
Answer :
Form is a webpage which contains elements like text fields, checkboxes, button etc. These web pages look like normal
white sheet of paper consisting of significant spaces information to be entered by users.
Marketed by:
LEARNING OBJECTIVES
After studying this unit, a student will have thorough knowledge about the following key concepts,
Ø Script tag , Document Object Model
Ø Document object, Forms collection and Images collection with its properties and methods
Ø Variables, Operators and its types and Functions
Ø Control Statements, Looping and Events
Ø Built-in Objects with its properties and methods
Ø Form Validation and Regular Expressions
Ø Select Box Options, Radio Buttons and check boxes,
Ø Form Enhancements and Java script Libraries
Ø Meta Tags, http-equiv and content attributes
Ø Pre-publishing Tests, Pre-release Tests, Link Checking and Checking Color Depths.
Ø Meta tags and its attributes
Ø Testing the site
Ø Different things to get the site on web
Ø Different pointers to make more people aware of the site
Ø Understanding the visitors.
INTRODUCTION
JavaScript is a programming language that supports to object oriented methodologies. It facilitates the inclusion of
certain executable data along with it. JavaScript can also contain dynamic data which can interact with the users,
dynamically create HTML context and can control the actions of browser. It provides various types of operators,
conditional statements, iterative statements, arrays, objects etc. JavaScript provides different types of objects such
as math object, string object, date object, boolean and number object and also some event handling techniques.
JavaScript can interact with web pages in various ways. Implementation of Javascript is described in this unit.The
javascripts can be created using basic scripts and Pre-written javascript libraries. The developed site is represented
to users and is put on the web. Tests are performed on it to validate the documents, links, and to make sure that
the site works in other browsers.
PART-A
SHORT QUESTIONS WITH SOLUTIONS
Q1. Write the structure of java script program.
Answer :
The structure of javascript code begin with the tag <script language = “javascript”>. This tag validates the javascript and
minimizes the occurrence of errors. It ends with </script>.
<script language = “javascript”>
{
javascript code;
}
</script>
Q2. Write a short note on DOM.
Answer :
Document object model or DOM is an interface using which given programs/scripts can dynamically alter (arrange,
format etc.) the contents of a given web document. Here, one has to remember that DOM remains a language and platform
independent interface. Also, the given web document can further be processed (if required) and the result of which can be
induced in it again.
Q3. What is a variable in java script? How to declare a variable?
Answer : Model Paper-I, Q6
Variable
A variable is a data item that stores the values defined by the user. It can be manipulated at any time. In JavaScript, the
variables are same as the other programming language variables. If a value is assigned to a variable then this is called assignment.
Declaring a Variable
Variables declared with ‘var’ keyword.
var variable = value;
var a = 10;
Q4. Define functions in javascripts.
Answer : Model Paper-II, Q6
A function is a self contained block of code that performs specific and well defined tasks. It simplifies complex task by
dividing the program into modules.
A function definition is the complete description of a particular operation. Actually a function definition tells what a
function does and how it performs. A function definition contains a function body (a block of statements) in addition to function
name, arguments list and return type.
Q5. Write about ‘string’ object.
Answer :
String function forms one of the important consequences in JavaScript. In general terms, strings refer to series of
characters (such as alphabets, special characters, numerics or combination of them) that are closed within double quotes.
Like math, even strings are treated as object which supports numerous methods.
Length is the main property used for string object. It is used to specify the count or number of a characters given in a
string.
Q6. Write a short note on Date Objects.
Answer :
Date forms one of the important specifications in almost every programming discipline. Hence, Java scripts provides a
date class for this purpose. This class includes a set of methods to access the date.
174 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-3 COMPUTER SCIENCE PAPER-VIII (B)
Globally, date/time is recognized in two ways i.e., UTC 1. schema
and local time. Universal time as the name suggests is a standard 2. name
that is followed all over the world. On the other hand, local time
3. content
is the time of the system where the script is currently residing.
4. http-equiv.
Date object can be created in the following way,
Here, the name and content attributes, http-equiv and
var currentdate = new date ( ); content attributes are used together.
On the execution, the date object simply captures the Q10. What are the two different stages of testing?
date of local system (in which it is executing) at that instant and
Answer :
returns the value (which is nothing but the time in milliseconds)
to current date variable. The returned value is the time started The two different stages in the process of testing are
from 0 clock, January 1st 1970. The date constructor in the above given below,
declaration is empty (i.e., without any parameters). Different 1. Pre-publishing Tests
values can be obtained by passing parameters to this constructor.
The tests that are performed on the system before
Q7. What is an array in java script? exposing them to the users are known as pre-publishing
Answer : Model Paper-II, Q6 tests.
An array contains a set of similar items. But in javascript 2. Pre-release Tests
an array can contain different items. Arrays here are similar The tests that are performed on a server before publishing
to structure variables. But they can be accessed randomly are known as pre-release tests.
by making use of index and the array name. Thus, arrays in
javascript are also called as associative arrays. This feature Q11. List the different points used to make people
makes javascript arrays distinct than arrays of other languages. aware of the site.
An array can be declared as follows, Answer : Model Paper-II, Q7
var arr; The different pointers to make more people aware of the
Elements can be allocated to this array by using the site are as follows,
below statement, 1. Always mention the URL
arr = new Array(10); 2. Forums, communities, and social Networks
An array is not initialized while it is allocated. 3. Check for trade sites and directories
Q8. List any two mathematical functions with syntax 4. Reciprocal links
and examples.
5. Look at your competition
Answer :
6. Make it easy for people to link to you
(i) Function : min( )
7. Pay-per-click advertising
Description : Displays minimum of two or list of
numerical values entered into it. 8. Display advertising
Usage : document.writeln(min(2, 5)); //output 2 9. Create an E-mail news letter.
(ii) Function : sqrt( ) Q12. Write a short note on domain name.
Description : It displays the square root of the value Answer : Model Paper-III, Q7
entered into it.
The domain name is an address that is provided to the
Usage : document.writeln(sqrt(4)); //output 2 users of the market for communicating through online/internet.
Q9. Write a short note on meta tags.
Example
Answer : Model Paper-I, Q7
siapublishers.com, hrstoppro.com
The meta tag provides the information related to the
There are many domain regestration companies for
page indexing for the search engines. The meta information is
simply defined as “information about information”. registering a domain name for the site. So, choose a company
and register your domain name. Most of the companies provide
Example
suffix as.com where as some other companies provides the
<meta name = “description” content = “SIA publishers
suffix based on the country. For example, .co.in for India, .co.
and distributors pvt Ltd”/>
for UK, and .ru for Russia, so on. .me.uk is the suffix given to
Generally, a meta tag can take four universal attributes
the personal sites in UK, .info is provided to the information-
(dir, lang, xml:lang and title) and four other attributes that are
specific to the <meta> element. They are as follows, based sites, .org is provided to the organizations.
PART-B
ESSAY QUESTIONS WITH SOLUTIONS
3.1 LEARNING JAVASCRIPT
The web pages contain the XHTML code as well as javascript code. Javascripts can be added to the webpage in two ways.
One way is to add the code within <script> and </script> tags. The purpose of the <script> tag is to notify the browser that the
contents inside the <script> tag are to be considered as the script and they should be interpreted by the respective interpreter.
Consider the below example,
<script language = “JavaScript”>
Javascript statements
</script>
In the above code snippet, the language attribute is optional. Multiple scripts can be inserted in an XHTML document.
All together form a single program along with the order in which they are declared. The interpreter is responsible for interpreting
the program along with statements from top to bottom.
Example
<html>
<head>
<title>JavaScript program </title>
</head>
<body>
<script language = “JAVASCRIPT”>
document.writeln(“Welcome to SIA Group”);
</script>
</body>
</html>
Output
The second way to add the javascript into XHTML is to identify the code available in the external source file. This file
should be made to refer from within the XHTML. This file should be saved with extension .js. It is the XHTML program which
refers this external file. The <script> tag contains an attribute src that refers the external javascript file name.
<script language = “JavaScript” src = “source.js”>
</script>
The source file must be located in the directory which contains the XHTML file. Even this method allows multiple javascript
files to be referred. A script tag for every file must be used in case of multiple files. This method is useful when the javascript
code is lengthy.
A single xhtml document can have any number of scripts and can be used in three different sections as follows,
(i) <head>
The script element is used in the <head> section of the page and is called whenever an event is triggered.
(ii) <body>
The script element is used in the <body> section of the page. Whenever a script is run a page is loaded.
(iii) External File
When an link is provided in <head> section then the script is treated as if it is in this <head> section. It occurrs whenever
an event is triggered. When it is provided in <body> section then the script is treated as it it is in the <body> section and executed
when the page is load.
Q14. Write about comments and <no script> element in Javascript.
Answer :
Comments
Comments in Javascript can be used in the following two ways,
(i) A comment is provided in a one line by using two forward slash(//) after the statement in the same line shown as below,
<script type = “text/javascript”>
document.write(“javascript Program”) //This text is displayed on screen
</script>
(ii) A comment can be provided in multiple lines by using the opening characters /* and closing characters */ shown as below,
/* this is a javascript program.
It contains multiline comments*/
<noscript> Element
This tag displays an alternative content with in a document for the javascript users who are disabled. It can contain
any XHTML content provided by the author.
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 177
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
3.1.2 The Document Object Model (iii) Area Collection
Q15. Explain about Document Object Model. It specifies the image maps which use an
<area>element present in the document.
Answer :
(iv) Forms Collection
Document Object Model
It specifies the <form> tags present in the document.
Document object model or DOM is an interface (v) Image Collection
using which given programs/scripts can dynamically alter
(arrange, format etc.) the contents of a given web document. It specifies the images present in the document.
Here, one has to remember that DOM remains a language
(vi) Link Collection
and platform independent interface. Also the given web
document can further be processed (if required) and the It specifies the hyperlinks present in the document.
result of which can be induced in it again.
Forms contains the child objects which are used to
Level 0 HTML Document Object Model specify various types of form controls that are shown on
the form such as Button, Checkbox, File upload, Hidden,
The following figure illustrates the level 0 HTML Option, Password, Radio, Reset, Select, Submit, Text,
document object model which contains different child TextArea.
objects that specifies the collection of similar tags present
in a document. Example
Option <body>
Form
Password <script type=“text/javascript”>
function display()
Image Radio
{
Reset
var name=document.form1.name.value;
Link Select
alert(“Welcome:”+name);
Submit
}
Text
</script>
TextArea
<form name=“form1”>
Figure: Level 0 HTML Document Object Model Enter Name:<input type=“text” name=“name”/>
(i) Anchor Collection <input type=“button” onclick=“display()”
value=“print name”/>
It specifies the anchor elements used in a document
for linking. </form>
(ii) Applet Collection </body>
It specifies the applets present in a document. </html>
178 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-3 COMPUTER SCIENCE PAPER-VIII (B)
Output
DOM provides a script to access the content of the form (forms collection) and the two links (links collection).
Accessing Values Using Dot Notation
The object can be accessed by a dot notation.
Example
document.links[0].href
In the above example, the first link in the document is accessed by the links i.e., a child object of the document object.
Here,
(i) The document specifies that document object is accessed by a user.
(ii) Links present in the links collection.
(iii) [0] specifies the first link of the document.
(iv) href specifies to retrieve the property for the given link.
Q16. Write about document object with its properties and methods.
Answer :
Document Object
The word “Document” in terms of programming aspects refers to the page which will be displayed as soon as the browser
window loads. It is a web page which can be created and displayed on browser.
Properties of Document Object
The following are the different properties of a document object.
1. alinkcolor
The color that has to be used to display the links in the document is defined by alinkcolor property.It can be used for both
read and write.
2. bgcolor
The bgcolor property indicates the background color of the document. It can be used for both read and write.
3. fgcolor
The fgcolor property indicates the foreground color (i.e., the text color in the document). It can be used for both read and
write.
4. lastModified
The lastModified property indicates the date on which the document was modified recently.
5. linkcolor
The linkcolor property indicates the color that has to be used for hyperlinks while displaying them in the document.
6. referrer
The referrer property indicates the URL of the document that refers the current document.
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 179
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
7. title
This property defines the title of the document as it is defined between the <title></title> tags.
8. vlinkcolor
The vlinkcolor property indicates the color that has to be used for the links that are already visited by the current user
while displaying them in the document.
The above properties can be accessed by using dot notation.
Example
Title of the document can be accessed by using the following syntax,
document.title
Methods of Document Object
The following are the methods of document object.
(i) write(String)
It is used for adding text or elements to the document.
(ii) writeln(String)
It is used for adding a new line at the ending of the output.
Example
<!DOCTYPE html>
<html>
<body>
<p>Document Object Example</p>
<pre>
<script>
document.writeln(“Hello”);
document.writeln(“World!”);
</script>
</pre>
</body>
</html>
Output
Q17. Explain about forms collection and form elements with their properties and methods.
Answer :
Forms Collection
A form object is an array that contains elements of a form. The elements of this array object of the form can be
accessed by using elements property of that object. These elements contain only the form fields. The individual elements
are accessed using ordinal number or the name of the element as an index.
180 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-3 COMPUTER SCIENCE PAPER-VIII (B)
Properties of Form Objects Properties of Form Elements
The following are the properties of form objects, The following are the properties of the form elements
(i) action used in the form.
(i) checked
It indicates the action attribute present in the <form>
element. It can be used for both read and write. Checked property returns true when a form element is
checked and it returns false when form element is not
(ii) length
checked. It is used for both read and write. This property
It specifies the number of form controls present in the is used by checkboxes and radiobuttons.
form. It is used only to read. (ii) disabled
(iii) method Disabled property returns true when it is disabled. It is
It indicates the value of an method attribute as get or used for both read and write. This property is used by
post in the <form> element. It is used for both read and all form elements except hidden elements.
write. (iii) form
(iv) name Form property is used to return a part of reference. It
It specifies the name attribute in the <form> element. It is used only to read. This property is used by all form
is used only to read. elements.
(v) target (iv) length
It specifies the target attribute in the <form> element. It Length property is used to return the count or the number
is used for both read and write. of options present in the <select> element. This is used
only to read. This can be used by select boxes.
Methods of Form Objects
(v) name
The following are the methods form objects,
Name property is used to access the value of the name
(a) submit( ) attribute. It is used only to read. This can be used by all
A form is submitted using submit( ) method. When the the form elements.
submit( ) method of the form is clicked, then the handler of (vi) Selectedindex
the submit event is called. All the form elements are checked Selectedindex property is used to return the index
inside the handler of submit event whether they contain correct number of the selected item in the form. It is used for
value. A form is submitted by calling submit( ) only when it both read and write. This can be used by select boxes.
passes this phase successfully. The URL that is specified by the (vii) type
action attribute is loaded or current page is loaded if no action
Type property is used to return the type of a form control.
attribute is specified.
It is used only to read. This can be used by all the form
All the desired tasks need to be performed before elements.
applying submit method. There must be a reference to the form (viii) value
object by using HTML DOM or other methods to invoke the
The value property is used to access the value attribute
submit( ) method on it.
given to the element or the content of a text input. It is
Example used for both read and write. This can be used by all the
document.forms[0]. submit( ); form elements.
(b) reset( ) Methods of Form Elements
The reset( )method is used to set the form fields to their The following are the methods of form elements.
default values. User need to have a reference to the form element (i) blur( )
before invoking this method. This is used by all the form elements except hidden
Form Elements elements. It forwards the focus present on the currently
The following are the different things used with the active element to the next element in the tabbing order.
elements in a form. (ii) click( )
(i) textfields This is used by all the form elements except text
elements. It simulates the mouse click on particular
This is used to read the user entered data or write the
element.
new data.
(iii) focus( )
(ii) checkboxes and radiobuttons
This is used by all the form elements except hidden
This is used for testing whether checked or unchecked. elements. It provides focus on the element.
(iii) buttons (iv) select( )
This is disabled whenever an user chooses any option. This is used by text elements except hidden elements.
(iv) select Boxes It is used to select the text of the element.
This is used for selecting an option from the list of pre- An example to illustrate different form elements is as
define options. given below,
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 181
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Example
<html>
<title>Forms</title>
<body>
<h1>Application Form</h1>
<form>
<table>
<tr>
<td>
<label for= “name”>Name</label>
</td>
<td>
<input type= “text” id= “name” name= “username”>
</td>
</tr>
<tr>
<td>
<label for= “email”>Email</label>
</td>
<td>
<input type= “text” id= “email” name= “usermail”>
</td>
</tr>
<tr>
<td>
<label for= “pass”>Password</label>
</td>
<td>
<input type= “password” id= “pass”>
</td>
</tr>
<tr>
<td>
<label for= “photo”>Photo</label>
</td>
<td>
<input type= “file” id= “photo”>
</td>
</tr>
<tr>
<td>
<label>Languages known</label>
</td>
<td>
<label>
<input type= “checkbox”> English</label>
<label>
<input type= “checkbox”> Telugu</label>
<label>
182 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-3 COMPUTER SCIENCE PAPER-VIII (B)
<input type= “checkbox”> Hindi</label>
</td>
</tr>
<tr>
<td>
<label>Gender</label>
</td>
<td>
<label>
<input type= “radio” value= “f” name= “gender”>
Female</label>
<label>
<input value= “m” type= “radio” name= “gender”>
Male</label>
</td>
</tr>
<tr>
<td>
<label for= “city”>City</label>
</td>
<td>
<select id= “city” name= “city”>
<option>--Select City--</option>
<option>Hyderabad</option>
<option>Warangal</option>
<option>Bangalore</option>
<option>Chennai</option>
</select>
</td>
</tr>
<tr>
<td>
<label>Address</label>
</td>
<td>
<textarea rows= “4” cols= “40”></textarea>
</td>
</tr>
<tr>
<td></td>
<td>
<input type= “submit” value= “Submit”>
<input type= “reset”>
</td>
</tr>
</table>
</form>
</body>
</html>
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 183
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Output
JavaScript does not support the blocked scope. This is the scope wherein every set of braces will have their own scope.
Q21. What is an operator? What are the different types of operators?
Answer : Model Paper-II, Q11(a)
Operator
An operator performs mathematical or logical operations. They are used to manipulate data and variables called operands.
It tells the computer about the operation to be performed on the operands.
Types of Operators
The various types of operators used in javascript are as follows,
1. Arithmetic Operators
Arithmetic operators are the mathematical operators that are used to perform basic arithmetic operations. Various
arithmetic operators are as follows,
(i) Addition (+)
(ii) Subtraction (–)
(iii) Multiplication (*)
(iv) Division (/)
(v) Modulus (%)
(vi) Increment (++)
(vii) Decrement (– –).
(i) Addition (+) Operator
It is a addition/plus operator which performs numeric addition. It performs addition operation when used on integers and
it performs concatenation when used on strings.
Examples
(a) var sum = 6 + 4; //result will be 10
(b) var value = “Hello” + “World”; //result will be Hello World
(ii) Subtraction(–) Operator
It is a subtraction/minus operator that is used to perform numerical subtraction.
Example
result = 5 – 2; //result will be 3.
188 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-3 COMPUTER SCIENCE PAPER-VIII (B)
(iii) Multiplication(*) Operator (b) Pre Decrement
It is a multiplication operator that is used to perform x=2
numerical multiplication.
y = – – x; //y will be 1
Example
Example
result = 6 * 2; //result will be 12
<html>
(iv) Division(/) Operator
<head>
It is a division operator which is used to perform
numerical division. <title>Arithmetic operators</title>
Example </head>
result = 10/2; //result will be 5 <body>
(v) Modulus(%) Operator <script language = “JAVASCRIPT”>
It is a modulus operator which returns remainder as the var a=5;
result.
var b=4;
Example
var linebreak = “<br/>”;
result = 5 % 2; //result will be 1
document.write(“a+b=” + (a+b));
(vi) Increment(++) Operator
document.write(linebreak);
It is an increment operator which increments the value
by 1. There are two types of increment operators namely document.write(“a - b =”+ (a-b));
pre increment and post increment. The pre increment
operator returns the final result after incrementing. document.write(linebreak);
The post increment operator returns the value before document.write(“a*b =”+ (a*b));
incrementing the value.
document.write(linebreak);
Example
document.write(“a / b =”+ (a/b));
(a) Post Increment
document.write(linebreak);
x = 2;
y = x + +; //y value will be 2 document.write(“a % b =”+ (a%b));
Example document.write(linebreak);
x = 2; </body>
y = x – –; //y will be 2 </html>
2. Assignment Operators
Assignment operators are used to assign values to variables. The basic assignment operator is ‘=’ which assigns the value
at the right side to the operand at its left side. The below tables shows various assignment operators.
Operator Example
(i) += x + = y (or) x = x + y
(ii) –= a – = b (or) a = a – b
(iii) *= a* = b (or) a = a * b
(iv) /= a / = b (or) a = a / b
(v) %= a % = b (or) a = a % b
(vi) << = a << = b (or)a = a << b
(vii) >> = a >> = b (or) a = a >> b
(viii) >>> = a >>> = b (or) a = a >>> b
(ix) &= a & = b (or) a = a & b
(x) |= a | = n (or) a = a | b
(xi) ^= a ^ = b (or) a = a ^ b
Example
<html>
<body>
<title>Assignment Operators</title>
<script type=“text/javascript”>
var a = 15;
var b = 12;
var linebreak = “<br />”;
document.write(“Value of a => (a = b) =>”);
result = (a = b);
document.write(result);
document.write(linebreak);
document.write(“Value of a => (a += b) =>”);
result = (a += b);
document.write(result);
document.write(linebreak);
document.write(“Value of a => (a -= b) =>”);
result = (a -= b);
document.write(result);
document.write(linebreak);
document.write(“Value of a => (a *= b) =>”);
result = (a *= b);
document.write(result);
document.write(linebreak);
document.write(“Value of a => (a /= b) => “);
190 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-3 COMPUTER SCIENCE PAPER-VIII (B)
result = (a /= b);
document.write(result);
document.write(linebreak);
document.write(“Value of a => (a %= b) =>”);
result = (a %= b);
document.write(result);
document.write(linebreak);
document.write(“Value of a => (a <<= b) =>”);
result = (a <<= b);
document.write(result);
document.write(linebreak);
document.write(“Value of a => (a >>= b) =>”);
result = (a >>= b);
document.write(result);
document.write(linebreak);
document.write(“Value of a => (a >>>= b) =>”);
result = (a >>>= b);
document.write(result);
document.write(linebreak);
document.write(“Value of a => (a &= b) =>”);
result = (a &= b);
document.write(result);
document.write(linebreak);
document.write(“Value of a => (a != b) =>”);
result = (a != b);
document.write(result);
document.write(linebreak);
document.write(“Value of a => (a ^= b) =>”);
result = (a ^= b);
document.write(result);
document.write(linebreak);
</script>
</body>
</html>
Output
5. String Operators
“+” operator is used for adding the text to the strings.
Example
word1 = “Hello”
word2 = “World”
word = word1 + word2
Concatenation is defined as the addition operation on two strings
Program
<html>
<body>
<title>String Operator</title>
<p id=“demo”></p>
<script>
var a = “Hello”;
var b = “World”;
c=a+b;
document.write(c);
</script>
</body>
</html>
Output
}
(iii) Function Call
A function can be called by using function name and a list of actual parameters enclosed in paranthesis. When a function
call is encountered, the control is transferred to the respective function, it is executed and the return value is returned to the
function which called it.
Syntax
function_name(parameters)
Example
<HTML>
<HEAD>
<TITLE>Functions</TITLE>
<SCRIPT>
function hello( )
{
document.write(“Hello”);
}
hello(); //function calling
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
Output
Return Statement
Return statement is used to return a value or a result. This statement is used to specify the value that is returned when
a function is called.
Example
Consider the below example that calculates the area of a rectangle by using a function,
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 195
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Program
<html>
<head>
<script type=“text/JavaScript”>
function Area_Rectangle(length, width)
{
area = length * width;
return area;
}
</script>
<title>Area of a Rectangle</title>
</head>
<body>
<form name=“frmArea”>
Enter the length and width of your rectangle to calculate the area:<br />
Length: <input type=“text” name=“txtLength” size=“4” /><br />
Width: <input type=“text” name=“txtWidth” size=“4” /><br />
<input type=“button” value= “Calculate Area” onclick= “alert(Area_Rectangle(document.frmArea.txtLength.value,
document.frmArea.txtWidth.value))” />
</form>
</body>
</html>
Output
2. if-else
‘if-else’ is an extension to ‘if’ control statement. The only difference between them is the ‘else’ statement contain certain
block of statement(s) which get’s executed only if its superior ‘if’ condition becomes false.
Syntax
if (condition)
statement;
else
statement;
Example
<html>
<head>
<title>Example of If-else Statement</title>
</head>
<body>
<script language = “JAVASCRIPT”>
var x=-2;
if(x>0)
{
document.write(x + “is a positive number”);
}
else
{
document.write(x + “is a negative number”);
}
</script>
</body>
</html>
Output
3. do-while Loop
do-while loop is same as that of while loop but the condition for it is specified at the end of the loop. The general syntax
of it is as follows,
Syntax
do
{
Statements;
}
while(condition);
The body of the loop gets executed atleast once even if the specified condition is false.
Example
<html>
<body>
<script type=”text/javascript”>
In the above program, the execution terminates when a break statement is encountered.
Event Description
onload It occurs when the page loads (this can be used to load images, documents, frameset).
onunload It occurs when the user quits a document or frameset i.e., a page is unloaded.
onclick It occurs when a link, client side image map area, or a form element (like button) is clicked.
ondbclick It occurs when an element is double clicked.
onmousedown It occurs when the user presses a mouse button
onmouseup It occurs when the user releases a mouse button
onmouseover It occurs when the mouse is moved over a link or an area of client side image map.
onmousemove It occurs when the user moves the mouse.
onmouseout It occurs when the mouse is moved out of a link or an area of client side image map.
onkeypress It occurs when the key is pressed and released over the element.
onkeydown It occurs when the user presses a key.
onkeyup It occur when the user releases the key.
onfocus This event will be called when an element like a document, window, frameset, or form element
gets the current input focus.
onsubmit It occurs when the user presses a submit button.
onreset It occurs when the user clicks the reset button.
onselect It occurs when the text is selected in a text field or a text area.
onblur It invokes as soon as any text, data or image turns blur (or object losses its focus).
onchange It invokes whenever data in any of the HTML control (textarea, textfield etc.) gets changed.
202 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-3 COMPUTER SCIENCE PAPER-VIII (B)
Example
<a href = “ ”
onmouseover = “document.images.link.src = ‘images/click-img1.fig’;”
onmouseout = “document.images.link.src = ‘images/click-img2.gif’;”>
<img src = “images/click-img2.gif” width = “150” height = “100” border = “0” name = “links”>
</a>
Program
Events
<HTML>
<HEAD>
<TITLE>Script to demonstrate the usage of frequently used events</TITLE>
</HEAD>
<BODY onLoad=’alert(“Examples of javascript events”)’ >
<H1 align=”center”>Javascript Events</H1>
<ul>
<li>onBlur EventHandler:
<input type=text value=”click here and see the result”
size=”20” onBlur= ‘alert(“NOT CLEAR!”)’>
<BR>
<BR>
<li>Onclick Eventhandler:
<input type=button value=”click here” onClick= ‘alert(“Clicked”)’>
<BR>
<BR>
<li>onChangeEventHandler:
<input type=text value=”Alter the text here” size=20 onChange=’alert(“Changed”)’)>
<BR>
<BR>
<li>onDblclick Eventhandler:
<input type=button value=”Double click here” onDblClick=’alert(“Double clicked”)’>
<BR>
<BR>
<li>onFocus Eventhandler:
<input type=text value=”click here” onFocus=’alert(“Focus gained”)’>
<BR>
<BR>
<li>onKeyDown Eventhandler:
<input type=text value=”Press any key and release” size=20 onKeyDown=’alert (“Key Down!”)’>
<BR>
<BR>
<li>onKeyPress Eventhandler:
<input type=text value=”Press any key here” size=20 onKeyPress=’alert (“key was pressed”)’>
<BR>
<BR>
<li>onKeyUp Eventhandler:
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 203
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
<input type=text value=”Press any key and release” onKeyUp=’alert(“Key up”)’>
<BR>
<BR>
<li>onMouseDown Eventhandler:
<input type=text value=”click mouse key don’t release”size=20
onMouseDown=’alert(“Mouse Down”)’>
<BR>
<BR>
<li>onMouseMove Eventhandler:
Traverse the mouse through this text
<A href=” “onMouseMove=’alert(“mouse traversed”)’>Sure Publications</A>
<BR>
<BR>
<li>onMouseOut Eventhandler:
Place the mouse pointer here
<A href=” “onMouseOut=’alert(“mouse out”)’>Javascript programming</A> Release here
<BR>
<BR>
<li>onMouseUp EventHandler:
<input type=”Button” value=”Click Me” onMouseUp=’alert(“MouseUp”)’>
<BR>
<BR>
<li>onReset EventHandler:
<input type=”RESET” value=”ResetDemo”>
<BR>
<BR>
<li>onSelect EventHandler:
<input type=”text” value=”Select me” size=20 onSelect=’alert(“TextSelected”)’>
<BR>
<BR>
<li>onSubmit EventHandler:
<input type=”submit” value=”submit”>
<BR>
<BR>
<li>onUnLoad event handler:
Follow the given link <a href=”https://globaljobfair.com”>GlobalJobFair</a>
</A>
<BR>
<BR>
</ul>
</BODY>
</HTML>
204 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-3 COMPUTER SCIENCE PAPER-VIII (B)
Output
Method Description
Example
<html>
<head>
<title>String Objects</title>
</head>
<body>
<script type=”text/javascript”>
var str = new String( “SIA Publishers & Distributors” );
var URL = “http://www.siapublishers.com/”;
206 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-3 COMPUTER SCIENCE PAPER-VIII (B)
var index = str.indexOf( “Publishers” );
document.writeln(“This is a method of str.charAt(0) :” + str.charAt(0));
document.write(“<br /><br />This is a method of indexOf found String :” + index );
var index = str.lastIndexOf( “Distributors” );
document.write(“<br /><br /> This is a method of lastIndexOf found String :” + index );
document.write(“<br /><br />This is a method of substr of (2,3) : “ + str.substr(2,3));
document.write(“<br /><br />This is a method of substring of (4,5) : “ + str.substring(4,5));
document.write(“<br /><br /> This is a method of LowerCase : “+str.toLowerCase( ));
document.write(“<br /><br /> This is a method of UpperCase : “ +str.toUpperCase( ));
document.write(“<br /><br /> This is a method of bold : “ +str.bold());
document.write(“<br /><br /> This is a method of fontcolor : “ +str.fontcolor( “Red” ));
document.write(“<br /><br /> This is a method of fontsize : “ +str.fontsize( 2 ));
document.write(“<br /><br /> This is a method of italics : “ +str.italics( 4));
document.write(“<br /><br /> This is a method of link : “ +str.link( URL ));
document.write(“<br /><br />This is a method of small : “ +str.small());
document.write(“<br /><br /> This is a method of strike : “ +str.strike());
document.write(“<br /><br />This is a method of sub : “ +str.sub());
document.write(“<br /><br /> This is a method of sup : “ +str.sup());
</script>
</body>
</html>
Output
Method Description
1. date( ) It is used to return a date object.
2. getDate( ) It is used to return the date of a date object i.e., from 1 to 31
3. getDay( ) It is used to return the day of a Date object. i.e., from 0 to 6 where 0 = Sunday, 1 =
Monday.
4. getMonth( ) It is used to return the month of a Date object i.e. From 0 to 11 where 0 = january.
5. getFullYear( ) It is used to return the year of a date object i.e., four digits.
6. getYear( ) It is used to return the year of a Date object by using only two digits i.e., from 0 to 99.
7. getHours( ) It is used to return the hours of a Date object. i.e., from 0 to 23.
8. getMinutes( ) It is used to return the minutes of a Date object. i.e., from 0 to 59.
9. getSeconds( ) It is used to return the seconds of a Date object. i.e., from 0 to 59.
10. getTime( ) It is used to return the number of milliseconds from midnight 1/1/1970.
11. getTimezoneOffset( ) It is used to return the time difference between the user’s computer and GMT.
12. parse( ) It is used to return the string date value that contains the number of Milliseconds from
january 01 1970 00 : 00 : 00.
13. setDate( ) It is used to set the date of the month in the Date object i.e., from 1 to 31.
14. setFullYear( ) It is used to set the year in the Date object. i.e., four digits.
15. setHours( ) It is used to set the hours in the Date object i.e., from 0 to 23.
16. setMinutes( ) It is used to set the minutes in the Date object. i.e., from 0 to 59.
17. setMonth( ) It is used to set the months in the Date object. i.e., from 0 to 11 where 0 = january.
18. setSeconds( ) It is used to set the seconds in the Date object. i.e., from 0 to 59.
19. setTime( ) It is used to set the milliseconds after 1/1/1970.
20. setYear( ) It is used to set the year in the Date object. i.e., from 00 to 99.
21. toGMTString( ) It is used for converting the Date object to string and set to GMT time zone.
22. toLocaleString( ) It is used for converting the Date object to a string and set to the current time zone
of the user.
23. toString( ) It is used for converting the Date object to the string.
Example
(i) Getting the Values
<html>
<head>
<title>Date Methods</title>
</head>
<body>
208 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-3 COMPUTER SCIENCE PAPER-VIII (B)
<script type=”text/javascript”>
var dt = Date();
document.write(“Date and Time :” + dt );
var dt = new Date( “Nov 27, 2018 12:35:00” );
document.write(“<br/><br/>Date is:” + dt.getDate() );
document.write(“<br/><br/>Day is :” + dt.getDay() );
document.write(“<br/><br/>Month is :” + dt.getMonth() );
document.write(“<br/><br/>FullYear is :” + dt.getFullYear() );
document.write(“<br/><br/>Year is :” + dt.getYear() );
document.write(“<br/><br/>Hours is :” + dt.getHours() );
document.write(“<br/><br/>Minutes is :” + dt.getMinutes() );
document.write(“<br/><br/>Seconds is :” + dt.getSeconds() )
document.write(“<br/><br/>Time is :” + dt.getTime() );
document.write(“<br/><br/>TimezoneOffset is :” + tz );
</script>
</body>
</html>
Output
Property Description
1. E It is used to return the value of base of a natural logarithm.
2. LN2 It is used to return the value of a natural logarithm of base 2.
3. LN10 It is used to return the value of a natural logarithm of base 10.
4. LOG2E It is used to return the value of a base-2 logarithm of E.
5. LOG10E It is used to return the value of a base-10 logarithm of E.
6. PI It is used to return the value of Pi.
7. SQRT1-2 It is used to return the value of 1 divided by the square root
of 2.
8. SQRT2 It is used to return the value of square root of 2.
Method Description
1. abs(x) It displays the absolute value of the numeric entity entered into it.
2. acos(x) It displays the arc cosine value of x.
3. asin(x) It displays the arcsine value of x.
4. atan(x) It displays the arctangent value of x.
5. atan2(y, x) It displays the tangent angle from the x-axis to a point.
6. ceil(x) It displays the rounded value of the integer entered into it. The values
displayed as output always remains greater than the value supplied.
7. cos(x) It displays trigonometric cosine value for the numeric value passed to it.
8. exp(x) It displays exponential(i.e., enumeric) value of the numeric value passed to it.
Answer :
Window Object
Each and every browser window or a frame contains a window object that is created by an instance of a <body> or
<frameset> element.
Example
The status property is used to change the text displayed on the browser’s status bar.
function statusBarTexts( )
</script>
The above code can be called in the <body> element as shown below,
Property Description
1. closed A boolean value is used to indicate as true if a window is
closed.
2. defaultstatus It is used to display the default message on the browser’s
window status bar.
3. document It is used to show a document object which is saved in that
window.
4. frames An array consists of named child frames in the current
window.
5. history A history object that has the information of visited URL’s in
the same window.
6. location The location object specifies the URL of the current window.
7. name The name is used to specify the name of the window.
8. status A status is a temporary message that is set at any time to
display in the status bar.
9. statusbar A statusbar specifies whether the status bar can be visible or
not. It can be known by a boolean value (true or false).
10. toolbar The toolbar specifies whether the toolbar can be visible or
not. Its can be known by a boolean value (true or false).
11. top Top specifies the reference for the topmost window when
different windows are opened on the desktop.
12. window Window specifies the currently opened window or a frame.
When the user enters the correct details then the output will be as follows,
The <form> tag contains onsubmit attribute whenever as user clicks on submit button then the value specified to it
is run/executed. The validate function is called to return true or false.
When the above code is executed then the following things are checked.
(i) Username should be of minimum length
(ii) Password should be of minimum length
(iii) The two passwords should match.
Validate( ) function can be implemented in two ways,
(a) By creating a single function for checking form
(b) By creating re-usable functions.
(a) Single Function Approach
A single function is created to check a form by using validate( ) function. The validate function is called and notified
about the current form by passing the parameter value.
function validate<form>
{
}
This keyword is used in the <form> element to call a function to indicate a form.
Variable contains the values of the user entered in the text controls. Value property is used to store the value entered
by the user.
Example
For answer refer Unit-III, Page No. 219, Q.No. 33, Topic: Example.
(b) Reusable Functions Approach
Reusable functions are also used for checking a form. JavaScript files contain functions which can be reused.
validate( ) function is used to call two more functions present in the javascript library.
(i) Validate( ) Confirm Password( )
It checks for the passwords field whether they are valid.
(ii) Validate Maximum Length( )
It checks for the minimum number of characters entered by the user in the field.
222 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-3 COMPUTER SCIENCE PAPER-VIII (B)
Example
<!DOCTYPE html>
<html>
<head>
<script>
function checkPassword(form)
{
password1 = form.password1.value;
password2 = form.password2.value;
if (password1 == ‘’)
alert (“Please enter the Password”);
else if (password2 == ‘’)
alert (“Please re-enter to confirm password”);
else if (password1 != password2) {
alert (“\n Passwords did not match!”)
return false;
}
else{
alert(“Passwords are matched: Welcome!”)
return true;
}
}
</script>
</head>
<body>
<form onSubmit = “return checkPassword(this)”>
<label for = “Username”>Username:</label>
<input type = “text” id = “Username” size = “10”/>
<span class = “msg”></span>
</div>
<div>
<label for = “password1”>password:</label>
<input type = “password” id = “password1” size “10”/>
<span class = “msg”></span>
</div>
<div>
<label for = “password2”>Confirm your password:</label>
<input type = “password” id = “password2” size = “10”/>
<span class = “msg”></span>
</div>
<div>
<input type = “submit” value = “login”/>
</div>
<div>
</form>
</body>
</html>
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 223
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
The above function is used for checking whether the user has entered minimum number of characters.
Output
replace( ) method
The replace( ) method in javascript is used for replacing certain characters in the document with the specified
characters.
Syntax
string.replace(Old String, new String);
Example
<!DOCTYPE html>
<html>
<body>
<p id=”demo”>hello world!</p>
<button onclick=”rep()”>Click</button>
<script>
function rep() {
var str = document.getElementById(“demo”).innerHTML;
var str1 = str.replace(“hello”, “hi”);
document.getElementById(“demo”).innerHTML = str1;
}
</script>
</body>
</html>
Output
The button through which user can select all will have a onclick event handler that calls SelectAll( ) function. It provides
the from control focus through focus( ) method and selects the control through select( ) method.
(ii) Check and Uncheck All Checkboxes
When a set of checkboxes are used the user must be able to select all the checkboxes or reset all of them at a time. This
is possible by using check( ) and uncheck( ) methods.
function check(field)
{
for(var i = 0; i > field.length; i++)
{
field[i].checked = true;
}
}
function uncheck(field)
{
for(var i = 0; i < field.length;i++)
The above code can be combined into a function that will be called through a button.
function checkUncheckAll (field)
{
var frm = field.form, i = 0;
for (i = 0; i < frm.length;i++)
{
if(frm [i].type = = ‘checkbox’ & & frm[i].name ! = ‘checkall’)
{
frm [i].checked = field.checked;
}
}
}
The above light box can be created by adding the below three scripts.
<script type = “text/javascript” src = “scripts/scriptaculous/prototype.js>
</script>
<script type = “text/javascript” src = “scripts/scriptaculous.js? load = effects, builder”> </script>
<script type = “text/javascript” src = “scripts/lightbox.js”> </script>
Code for creating the lines to the images in lightbox is as follows,
<a href = “images/img1.jpg” rel = “light box[Japan]”>
Image1</a>
<a href = “images/img2.jpg” rel = “light box[Japan]”>
Image2</a>
<a href = “images/img3.jpg” rel = “light box[Japan]”>
Image3</a>
Users can even add multiple lightboxes on the same page but with different names.
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 237
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Q47. Explain in brief about the following,
(i) Creating a Modal Window
(ii) Sortable tables with Mochikit.
Answer :
(i) Creating a Modal Window
A model window is a child window with which the user need to interact to return to main window.
The above model window makes use of script “Thickbox” along with Jquery library.
<script type = “text/javascript” src = “scripts/jquery/jquery –1.3.2.js”>
</script>
<script type = “text/javascript” src = “scripts/thickbox js”>
</script>
<link rel = “stylesheet” href = “scripts/thickbox.css” type = “text/css” media = “screen”/>
Code to add the content to modal window is,
<div id = “mypage”> <P>
Here is the modal window
</P> </div>
This code can be disabled on the page by using style sheet rule. Other than this, a link can also be added to the modal
window by using <a> element. It should start with class attribute with value thickbox.
(ii) Sortable Table with Mochikit
Users are allowed to create sortable table to reorder the table contents just by clicking the column heading. It is useful
to handle large tables where several users sort the data in several ways. The below table contains set of students details. The up
arrow beside “Id” heading represents that tables contents are sorted according to the id.
This concept makes use of a javascript library called Mochikit. The code to create sortable table is as follows,
<script type = “text/javascript” src = “scripts/Mochikit/Mochikit.js”> </script>
<script type = “text/javascript” src = “scripts/mochikit/examples/sorttab/sorttab.js”>
</script>
The headers must be differentiated from coloumns by using CSS styles. Inorder to sort the table the below three things
are needed.
The <table> element needs id attribute with value sortable table.
The <th> element must contains an attribute mochi for every column.
The <td> elements first row must be mochi:content.
238 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-3 COMPUTER SCIENCE PAPER-VIII (B)
Q48. Discuss about the following,
(i) Creating calendar with YUI
(ii) Auto completing text inputs with YUI.
Answer :
(i) Creating Calendar with YUI
YUI stands for Yahoo User Interface library. It is a large library that contains various types of functionalities in several
scripts. It is split into four sections, described as follows,
1. The heart of YUI contains three scripts namely Yahoo Global Object, DOM collection and event utility. Sometimes all
three are needed and sometimes only one or two of them are required.
2. The library utilities that offer the functionality that are useful in various tasks like libraries to create animated effects,
drag-and-drop functionality and image loading.
3. The library consists of scripts for creating various types of user interface controls like calendars, color pickers, text editors
and image carousels. The ‘cheat sheets” help to create the user interface components quickly.
4. A set of CSS stype sheets are used with UI controls to represent as desired.
Consider an example of YUI to add a calender to the web page. This needs three javascript files from YUI to be added
and a calender is script file.
<script type = “text/javascript” src = “scripts/yui/yahoo/yahoo.js”> </script>
<script type = “text/javascript” src = “scripts/yui/event/events.js”> </script>
<script type = “text/javascript” src = “scripts/yui/dom/dom.js”> </script>
<script type = “text/javascript” src = “scripts/yui/build/calendar”> </script>
A css file must above be added with YUI download.
<link type = “text/css” rel = “stylesheet” href = “scripts/YUI/sam/calendar.css”>
Finally, this can also be included in the script that calls the YUI library and files the <div> element with calender
<script>
Yahoo.namespace(“ex.calender”);
Yahoo.ex.calender.init = func( )
{
Yahoo.ex.calender.c1 = new Yahoo.widget.calender(“c1” “c1container”);
Yahoo.ex.calender.c1.render( );
}
Yahoo.util.event.onDomReddy(Yahoo.ex.Calendar.init);
</script>
The two different stages in the process of testing are given below,
1. Pre-publishing Tests
The tests that are performed on your system before showing it to anyone else are known as pre-publishing tests.
2. Pre-release Tests
The tests that are performed on a server before publishing are known as pre-release tests.
Validating HTML, XHTML and CSS
A validator is used to validate the opening and closing tags, the various attributes of the respective tags etc. Suppose if
a simple tag like </td> is missed in the code, it doesnot make any effect on the present browser but, it might not provide same
result on other systems when used.
Every version of HTML and XHTML has its own set of rules that directs the version of the language called as schema
or DTD. Here, the validator is used to check whether the page follows the rules of schema or DTD. The validator provides tags
that are missing in the page or any missing part of the markup.
An online validation tool at http://validator.w3.org/ is provided by W3C. It allows user to enter the URL of the page. The
markup validation service screen will be as shown in the below figure,
When the URL is entered, it will check for the errors in the page.
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 243
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Example
One disadvantage of W3C validation tool is that it validates the documents one after the other.
There are some other authoring tools that are used to validate the complete site. For example, Dreamwaver consists of
many new features to perform validation for XHTML pages in its Dreamweaver Mx version. A user can validate a page by simply
clicking on “shift + F6”. It generates the errors in the page as shown in the below diagram,
To make the Dreamweaver work properly, right-click on the run panel and select the setting dialog box in windows or option-
clic on mac operating system. The dialog box displays a wide range of document standards. Note that, all the checkboxes should
be unchecked except the one which user want to check. For example, if a user is trying to validate a XHTML 1.0 Transactional
document, then the respective box should be checked. This is shown in the below figure,
Dreamweaver has its own tools for checking links. This can be done by simpling clicking on ctrl + shift + F9.
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 245
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
3. Checking Color Depths
Check the color contrast to confirm whether it is clearly visible to people with colorblindness. This can be done by some
color checking tools. Some of them are as follows,
http://graybit.com/main.php
www.vischeck.com/vischeck/vischeckURL.php
www.snook.ca/technical/colour_contrast/colour.html.
4. Accessibility Checkers
Accessibility checkers are used to check whether the site has all the accessibility requirements. This also helps the site to
run efficiently on a wide range of devices that access the web. Some of the different online Accessibility checkers are as follows,
www.section508.info/
www.webaim.org/resources/wave
For instance, the above tools check whether an ‘alt’ attribute is used as an alternative but it doesnt inform about the text
that is to be displayed an behalf of the alternate image.
5. Checking in Different Versions of Browsers
It is very important to check the site in different versions of browsers. This is because, some of the browsers support the
elements used in coding and some don’t. Therefore, check the site in as many browsers as possible. Atleast, check in the latest
versions of browsers because the versions of the browser in a system cannot be installed simultaneously.
Most importantly, the site need to be checked in IE6, chrome, opera and safari browsers.
There are some tools that permit user to take screenshots about the presentation of web site in the different browsers.
Some of them are as follows,
www. browsercom.com/
http://browserlab.adobe.com/
http://browsershots.org/.
Some of the hosting companies support SFTP or secure FTP which is the variant of FTP. SFTP is known to be highly
secured and standard because the details like username and password will be encrypted when they sent to the server.
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 249
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Q56. Discuss in brief about the importance of directory structures and URLs.
Answer :
Importance of Directory Structures and URLs
Most of the people develop their very first website on their desktop or computer using relative URLs for all the images,
styles sheets, links and scripts. That means, all the links provided in the coding of a site will work on the web server without
modifications.
When a site is opened, it shows the URL in the browser window as like given below,
C:\User\webdesigning\example\Ex1.html
But when the site can switch to new site or URL then the URL will appears as follows,
http://www.ex.com/Ex1.html
Generally, in a site the relative URLs for images, styles, links and scripts will be declared as,
<img src = “c:\User\webdesigning\example\Ex1.jpg” alt = “logo”/>
But, when the site is switched to a new site or URL onto the web server, it doesn’t load the source image file. Therefore,
provide the image URL something like the following,
<img src = “examples/ex1.jpg” alt = “logo”/>
Thus, the page loads the image until and unless the example directory is deleted for the computer.
3.3.4 Telling the World About Your Site
Q57. What are the different pointers used to make more people aware of the site?
Answer : Model Paper-III, Q11(b)
The different pointers used to make more people aware of the site are as follows,
1. Always mention the URL
2. Content is king
3. Forums, communities, and social Networks
4. Check for trade sites and directories
5. Reciprocal links
6. Look at your competition
7. Make it easy for people to link to you
8. Pay-per-click advertising
9. Display advertising
10. Create an E-mail news letter.
1. Always Mention the URL
Mention the URL of the site where ever possible. Provide the URL in the brouchers, business cards, letterheads, adverts
and posters then the people will get to know about the site.
2. Content is King
Content is the king of the page. If the content provided is effective, useful, entertaining and informative then the people
will attract to the site easily. Try to provide the information in an easy and unique way rather than providing regularly.
Provide the updated information and update the existing information periodically by mentioning, “last update on particular
time and date”. Then, the user will get to know the information in the page is latest.
Publish the benefited from a Press Release, in PR news services like PR web(www.PRweb.com). Thus, the other bloggers
or journalist will choose the content and mentions it.
3. Forums, Communities and Social Networks
Different hobbies and industries have their own forums and online communities. Group of people that interested in the
same topic can be found on the social media like Facebook, Twitter etc.
Suppose, if user is a member of online community which is related to the site then they can start your profile in it with its
URL and photographs, and providing the URL of the site in the social media profiles. Then the site will become popular
among the people.
Interact with the other people by reacting and replying to their posts rather than only posting the site information and
publishing the website.
250 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
UNIT-3 COMPUTER SCIENCE PAPER-VIII (B)
4. Check for Trade Sites and Directories
Now a days, most of the trades and hobbies have their own site which provides the list of all other sites. Check for the
site which is relevant to the information of the site and request the relative sites.
For the listing of related sites, some trades may charge some money. In such situations, know the average number of visitors
visits the site and the monthly traffic before subscribing to their sites. Try to take a trail period to check the monthly traffic
and the number of visitors per month.
5. Reciprocal Links
Most of the smaller websites provide reciprocal links that means, their site will link to present site for linking itself to
them. In such cases, do not provide others links on the front page because it leads to populate their site than present site.
With this, the site will get better traffic from the sites that are related to the information in the site.
6. Look at Your Competition
Find the different competitors of the site and check who is linking to them. And, request them to link to the site as well.
7. Make it Easy for People to Link to You
Most of the webpage provides links to bookmark a page on services like Email, Twitter and facebook, etc. This is shown
in the below figure,
A simple and easier way to link these options is using the website known as www.addthis.com/ that offeres some simple
tools to create a link to share the link of the site with others.
Create a page with banners or button that helps the visitors to link to the site easily. Some websites like Oxfam include
the ads that are with attractive images and effective content.
Example
8. Pay-per-click Advertising
Pay-per-click is a type of advertising techniques in which marketer pay a specified amount for listing the web site on all
search engine results, which will appear by entering various keywords.
Two main factors decides the order of the advertisements to be appeared on the page. They are,
The amount of money paid for every click of an ad.
The count of users that clicks on the ad.
This is known as a best and cost-effective way to produce the traffic to the site. Some other like microsoft and Yahoo
provides similar services called adcenter and Yahoo! search marketing respectively.
Example
An example for pay-per-click advertising is given below,
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. 251
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
9. Display Advertising
Display advertising is an online advertising technique that forces the user to pay some amount for advertising about the
site on some other sites. It includes banner ads.
The companies charge for adverting the site in two ways. They are,
1. Cost-per-thousand impressions, named as CPM.
2. Cost to occupy some space on a particular site for some months or years.
10. Create an E-mail Newsletter
E-mail newsletter is a feature that is required when the content of the page is changing frequently. In this, when the
content is changed then an email will be sent to the subscriber saying the content is updated.
The following are the different tools to create and manage the e-mail lists,
www.MailChimp.com
www.CampaignMonitor.com.
These tools are used to send mail to the visitors and also helps in creating the subscription forms that are used to signup
for the users.
3.3.5 Understanding Your Visitors
Q58. What are the two different ways to learn about the visitors to the site?
Answer :
The two different ways to learn about the visitors to the site are as follows,
1. Log file analysis
2. Analytics software.
1. Log File Analysis
When a user requested for a file from the system then the server will record certain information about them like IP address,
operating system, browser type and stores them in a file called as log file. Most of the companies offers some tools to analyze
the visitors information.
2. Analytics Software
Analytics software uses a script for checking the log file and collected information about the visitors that is similar to
other. It also offers the tools to analyze the collected information.
Google ofters a free service tool called as Google Analytics (www.google.com/analytics). This provides a detail analysis
about the visitors like how they entered the site, how many times they have visited, how many files they have downloaded
(referred as hits). This uses the different static packages and collects the information which is useful to the site, and analyzes it.
The example of a report from the Google Analystics is as shown in the below figure,
INTERNAL ASSESSMENT
OBJECTIVE TYPE
I. Multiple Choice
1. The structure of a javascript code begins with the tag ______. [ ]
2. ______ is a programming language with direct support to the object oriented methodologies. [ ]
3. ______ function is used to convert the all lowercase letters to the equivalent upper case letters/characters. [ ]
7. ________ function is used to display the minimum of two number given to it. [ ]
10. ______ displays the number of times that visitors visited the site in a period of time. [ ]
6. ________ is a self contained block of code that performs specific and well defined tasks.
8. ________ is used to provide the information regarding the page indexing to the search engines.
9. ________ is defined as verifying different modules of the site under the real-time circumstances.
10. ________ displays the number of pages visited by the visitors on the site.
KEY
I. Multiple Choice
1. (c) 2. (a) 3. (b) 4. (d) 5. (c)
2. Client
3. Associative arrys
4. Variable
5. concat( )
6. Function
7. ceil( )
8. Meta tag
9. Pilot testing
Answer :
Java script is a programming language that support object oriented methodologies. It facilitates inclusion of certain
executable data along with it.
Q2. What are the uses of javascript?
Answer :
The uses of javascript are as follows,
(i) Java script is multi-functional i.e., it can be used as a client side scripting as well as server side.
(ii) It is used to provide an easy way of accessing document objects as well as it can manipulate almost all of these
objects.
Q3. Define variable in JavaScirpt.
Answer :
A variable is a data item that stores the user defined values. It can be manipulated at any time. In JavaScript, the variables
are same as the other programming language variables.
Q4. Define bandwidth.
Answer :
Bandwidth is defined as the amount of data that is permitted to the users to use on the site.
Answer :
Uptime is defined as the percentage of time that the site is available to the user.
For answer refer Unit-I, Page No. 3, Q.No. 4. For answer refer Unit-I, Page No. 69, Q.No. 64.
Q5. What is a frame in HTML? Give an example.
Answer : Important Question
Answer : Important Question For answer refer Unit-II, Page No. 80, Q.No. 2.
For answer refer Unit-I, Page No. 4, Q.No. 9. Q3. List the properties that influence the appearance
of the font.
Q9. Define with syntax <FONT> tag.
Answer : Important Question
Answer : Important Question
For answer refer Unit-I, Page No. 4, Q.No. 10. For answer refer Unit-II, Page No. 80, Q.No. 4.
ESSAY QUESTIONS Q4. What is a selector? List the types of selectors
in CSS.
Q10. Explain in detail about HTML.
Answer : Important Question
Answer : Important Question
For answer refer Unit-I, Page No. 5, Q.No. 11. For answer refer Unit-II, Page No. 81, Q.No. 5.
Q11. Discuss about presentational elements. Q5. Write about vertical-align property.
Answer : Important Question Answer : Important Question
For answer refer Unit-I, Page No. 15, Q.No. 20. For answer refer Unit-II, Page No. 81, Q.No. 6.
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. IQ.1
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
3
Q6. What are the different properties that are used
Unit-
to position the items on the page.
Answer : Important Question
For answer refer Unit-II, Page No. 81, Q.No. 9. For answer refer Unit-III, Page No. 1744, Q.No. 4.
Q9. List the advantages of fixed-width design and
Q3. What is an array in java script?
liquid design.
Answer : Important Question
Answer : Important Question
For answer refer Unit-II, Page No. 81, Q.No. 10. For answer refer Unit-III, Page No. 175, Q.No. 7.
ESSAY QUESTIONS Q4. Write a short note on meta tags.
Q10. How style sheets are specified into HTML Answer : Important Question
document?
For answer refer Unit-III, Page No. 175, Q.No. 9.
Answer : Important Question
For answer refer Unit-II, Page No. 82, Q.No. 12. Q5. List the different points used to make people
aware of the site.
Q11. Explain how the fonts can be controlled. List
and explain each of the properties that directly Answer : Important Question
affect the font and its appearance.
For answer refer Unit-III, Page No. 175, Q.No. 11.
Answer : Important Question
Q6. Write a short note on domain name.
For answer refer Unit-II, Page No. 89, Q.No. 18.
Q12. Discuss in detail about the dimensions of a Answer : Important Question
box. For answer refer Unit-III, Page No. 175, Q.No. 12.
Answer : Important Question
ESSAY QUESTIONS
For answer refer Unit-II, Page No. 111, Q.No. 27.
Q7. How a script is added to the webpage.
Q13. Explain in detail about background properties
of CSS3 with an example. Answer : Important Question
Answer : Important Question For answer refer Unit-III, Page No. 176, Q.No. 13.
For answer refer Unit-II, Page No. 117, Q.No. 29. Q8. What is an operator? What are the different
Q14. Discuss in brief about the composition and types of operators?
grids.
Answer : Important Question
Answer : Important Question
For answer refer Unit-III, Page No. 188, Q.No. 21.
For answer refer Unit-II, Page No. 142, Q.No. 44.
Q15. Write in detail about layout of forms. Q9. Write about form validation.
For answer refer Unit-II, Page No. 165, Q.No. 66. For answer refer Unit-III, Page No. 219, Q.No. 33.
IQ.2 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
Important Questions COMPUTER SCIENCE PAPER-VIII (B)
Q10. Write short notes on following,
(i) Focusing on first form item
(ii) Auto tabbing between fields.
Answer : Important Question
LIST OF PROGRAMS
UNIT - I
UNIT - II
UNIT - III
Answer :
Program
<html>
<title>Cafe site</title>
<body>
<h1>Irani Cafe</h1>
<h3>Charminar</h3>
<h4>Hyderabad</h4>
<h5>040-123456</h5>
<p>Branches:<br>Hyderabad<br>Bangalore</p>
<pre>
</pre>
<h6>iranicafe@gmail.com</h6>
</body>
</html>
Output
(b) Write a HTML program using phrase element tags <blockquote>, <cite>, <abbr>, <acronym>, <kbd>,
<address>.
Answer :
Program
<html>
<title>Phrase Element Tags</title>
<body>
<blockquote cite= “http://www.siapublishers.com/”>
About Us
</blockquote>
<img src= “SIAMAINLOGO.png” alt= “Error”>
<p><cite>SIA Group</cite> is one of the leading Publishers and book Distributors across the South India </p>
<p><abbr title= “Syed Ibadat Ali”>SIA</abbr> was initiated in the year 1979.</p>
<p><acronym title= “Syed Ibadat Ali”>SIA</acronym> was initiated in the year 1979.</p>
<address><a href= “support@siapublishers.com”>SIA</a>.<br>
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. LP.3
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
Visit us at:<br>
Putli Bowli Lane,<br>
Koti, Hyderabad,<br>
Telangana
</address><br>
<kbd>Enlightening Lives through Education</kbd>
</body>
</html>
Output
(b) Write a HTML page that displays ingredients and instructions to prepare a recipe.
Answer :
Program
<html>
<head>
<title>Recipe- Basic Vanilla Cake</title>
</head>
<body>
<h1>Recipe- Basic Vanilla Cake</h1>
<h2>Ingredients:</h2>
<ul>
<li>1 1/2 cup sifted cake flour</li>
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. LP.5
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
<li>1 1/2 table spoon baking powder</li>
<li>1/4 table spoon salt</li>
<li>1/2 cup unsalted butter</li>
<li>1 cup sugar</li>
<li>2 large eggs</li>
<li>1/2 table spoon vanilla extract</li>
<li>1/2 cup whole milk</li>
</ul>
<h2>Instructions:</h2>
<ol>
<li>Heat the oven to 400 degrees F. Lightly coat an 8-inch cake pan with butter and dust with all-purpose flour. Sift the
cake flour, baking powder, and salt into a large mixing bowl.</li>
<li>Beat in the butter one heaping 1/4 teaspoonful at a time, using an electric mixer set on low speed, until the mixture
resembles coarse sand. Beat in the sugar a tablespoon at a time, until the mixture resembles fine damp sand. Beat in the
eggs one at a time. Add the vanilla and milk, and beat on medium-high, just until blended. Do not overbeat.</li>
<li>Pour into the prepared pan and bake until a wooden skewer inserted in the center comes out clean—30 to 35 minutes.
Cool cake in the pan on a wire rack for 5 minutes.</li>
<li>Un-mold and cool completely. Ice with Browned-Butter Glaze.</li>
</ol>
<p>Before you begin, check baking powder expiration date. If it has passed, buy a fresh canister.</p>
</body>
</html>
Output
Q6. Write a HTML program to create a form using text inputs, password inputs, multiple line text input,
buttons, check boxes, radio buttons, select boxes, file select boxes.
Answer :
Program
<html>
<title>Forms</title>
<body>
<h1>Application Form</h1>
<form>
<table>
<tr>
<td>
<label for= “name”>Name</label>
</td>
<td>
<input type= “text” id= “name” name= “username”>
</td>
</tr>
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. LP.11
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
<tr> <input type= “radio” value= “f” name= “gender”>
<td> Female</label>
<label for= “email”>Email</label>
<label>
</td>
<input value= “m” type= “radio” name= “gender”>
<td>
Male</label>
<input type= “text” id= “email” name= “usermail”>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
<td> <td>
<td> <label>Address</label>
<label>Languages known</label> </td>
</td> <td>
<td> <textarea rows= “4” cols= “40”></textarea>
<label> </td>
<input type= “checkbox”> English</label> </tr>
<label> <tr>
<input type= “checkbox”> Telugu</label> <td></td>
<label>
<td>
<input type= “checkbox”> Hindi</label>
<input type= “submit” value= “Submit”>
</td>
<input type= “reset”>
</tr>
</td>
<tr>
</tr>
<td>
<label>Gender</label> </table>
</td> </form>
<td> </body>
<label> </html>
Q7. Write a HTML program to create a frames and links between frames.
Answer :
Program
f.html
<html>
<head>
<title>Master Page</title>
</head>
<frameset cols= “50%,50%”>
<frame src= “f1.html”>
<frame src= “f2.html”>
</frameset>
</html>
f1.html
<html>
<head>
<title>PAGE1</title>
</head>
<body>
Welcome to Page 1
<br>
Click Here <a href= “f3.html”> to link to page 3 </a>
</body>
</html>
When the user clicks on the ‘Click Here’ then the output will be as shown in below figure,
Red color
Blue color
Q9. Write a HTML program to create CSS on links, lists, tables and generated content.
Answer :
Program
<html>
<title>CSS onlinks, lists, tables and generated content</title>
<head>
<style type= “text/css”>
links.c { color: blue; }
li .a, b {list-style-type : decimal}
table {width : 350px ; border-collapse : separate ;}
td {font-size : 17px ; text-align : center ; border-width : 4px ; border-color : green ; border-style : solid ; border-spacing:
3pxpx ; 3px}
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. LP.15
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
blockquote:before{ content: open-quote; }
blockquote:after{ content: close-quote; }
</style>
</head>
<body>
<h1>CSS on Links</h1>
<links class= “c”><p><b><a href= “default.asp” target= “_blank”>Click here</a></b></p></links>
<h1>CSS on Lists</h1>
<ol>
<li class= “a”>ordered list style one</li>
<li class= “b”>ordered list style two</li>
</ol>
<h1>CSS on Tables<h1>
<table>
<tr>
<th>Fruits</th>
<th>color</th>
</tr>
<tr>
<td>Apple</td>
<td>green</td>
</tr>
<tr>
<td>Banana</td>
<td>yellow</td>
</tr>
<table>
<h3>CSS on Generated Content</h3>
<blockquote>Example of css on generated content</blockquote>
</body>
</html>
Output
Q11. Write a HTML program to create your college web site using for mobile device.
Answer :
Program
<html>
<head>
<title>SIA Home</title>
<meta charset=“utf-8”>
<meta name=“viewport” content=“width=device-width, initial-scale=1”>
<style>
@media screen and (max-width: 481px){
*{
box-sizing: border-box;
}
body {
margin: 0;
}
.header {
background-color: AQUA;
padding: 9px;
font-size: 40px;
}
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. LP.19
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
.topnav { </div>
overflow: hidden; <div class=“topnav”>
background-color: gray; <a href=“#”>Administration</a>
} <a href=“#”>Courses</a>
.topnav a { <a href=“#”>Examinations</a>
float: left; <a href=“#”>Affiliation</a>
display: block; <a href=“#”>Accredation</a>
color: #f2f2f2; <a href=“#”>About</a>
text-align: center; </div>
padding: 14px 16px; <div class=“row”>
text-decoration: none; <div class=“column side”>
} <h2>Quick Links</h2>
.topnav a:hover { <a href=“#”>Annual Reports</a><br><br>
background-color: #ddd; <a href=“#”>Classwork Timetables</a><br><br>
color: black; <a href=“#”>Holiday Notification</a><br><br>
} <a href=“#”>Student Activity center</a><br><br>
.column { <a href=“#”>Training & Placement</a><br><br>
float: left; <a href=“#”>Research</a><br><br>
padding: 8px; <a href=“#”>NBA Accredation</a><br><br>
} <a href=“#”>Academics</a><br><br>
.column.side { <a href=“#”>Almanac</a><br><br>
width: 25%; <a href=“#”>Departments</a><br><br>
background-color: silver; <a href=“#”>Contact Us</a>
} </div>
.column.middle { <div class=“column middle”>
width: 50%; <img src=“DSC00649.jpg” alt=“inaugral.jpg”
} height=“400” width=“530”>
.row:after { <p>The institution was started in 2017 with two
B.Tech programs (viz., Computer Science Engineering
content: “”;
and Electronics and Communication Engineering) in
display: table; sprawling lush green campus of 65 acres, in the area
clear: both; well connected by rail and road.</p>
} </div>
.column.side, .column.middle { <div class=“column side”>
width: 100%; <h2>Vision</h2>
} <p>To make our students technologically superior and
.footer { ethically strong by providing quality education with the
background-color: olive; help of our dedicated faculty and staff and thus improve
the quality of human life.</p>
padding: 7px;
<h3>Mission</h3>
text-align: center;
<p>To provide latest technical knowledge, analytical and
}
practical skills, managerial competence and interactive
} abilities to students, so that their employability is
</style> enhanced.
</head> To provide a strong human resource base for catering to
<body> the changing needs of the Industry and Commerce.
<div class=“header”> To inculcate a sense of brotherhood and national
<img src=“SIAMAINLOGO.png” alt=“inaugral. integrity.</p>
jpg” height=“50” width=“70” <h1><b> Institute of </div>
Technology and Science</b></h1> </image> </div>
LP.20 SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD.
Lab Practical with Solutions COMPUTER SCIENCE PAPER-VIII (B)
<div class=“footer”>
<p><b>Copy Right © 2018. All Rights Reserved by M.Nikhil</b></p>
</div>
</body>
</html>
Output
(b) Write a JavaScript program to wish good morning, good afternoon, good evening depending on
the current time.
Answer :
Program
<html>
<head>
<title>Example of Conditional statements</title>
</head>
<body>
<script type= “text/JavaScript”>
var date = new Date( );
var time = date.getHours( );
if (time < 12) {
document.write(‘Good Morning’);
}
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. LP.23
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
else if ( time >12 && time < 18) {
document.write(‘Good Afternoon’);
}
else {
document.write(‘Good Evening’);
}
</script>
</body>
</html>
Output
(b) Write a JavaScript program to print multiplication table of given number using loop.
Answer :
Program
<html>
<head>
<title>Multiplication Table</title>
</head>
<body>
<p>
<script type= “text/JavaScript”>
num = 5
i=1
while (i <= 10) {
document.write(num + “ x “ + i +” =” + (num * i) + “<br />” );
i ++
}
</script>
</p>
</body>
</html>
Output
Q16. Write a JavaScript program to create registration form and validate all fields using form validation.
Answer :
Program
form-validation.html
<html>
<head>
<title>Form validation</title>
<style type=“text/css”>
.formTitle {vertical-align:top; text-align:right;}
</style>
<script type=“text/JavaScript”>
function validate(form) {
var returnValue = true
var name=form.txtName.value
if (name== “ ”)
SIA PUBLISHERS AND DISTRIBUTORS PVT. LTD. LP.29
COMPUTER SCIENCE PAPER-VIII (B) WEB TECHNOLOGIES
{
returnValue = false;
alert(“You must enter a name”)
document.frmRegistration.txtName.focus();
}
var email=form.txtEmail.value
var rxEmail = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-z]{2,6}(\.[a-z]{2})?$/i;
if (!rxEmail.test(email))
{
returnValue = false;
alert(“You must enter a valid email address”)
document.frmRegistration.txtEmail.focus()
}
var phone=form.txtPhone.value
if (phone==“ ”)
{
returnValue = false;
alert(“You must enter your phone number”)
document.frmRegistration.txtPhone.focus();
}
var radioChosen = false;
var radioButtons = form.radGender;
for (var i=0; i<radioButtons.length; i++) {
if (radioButtons[i].checked)
{
radioChosen=true;
}
}
if (radioChosen == false) {
returnValue = false;
alert(“You must choose gender”);
}
var Address=form.txtAddress.value
var AddressWords = Address.split(“ ”);
if (Address==“ ”)
{
returnValue = false;
alert(“You must enter the address”)
document.frmRegistration.txtAddress.focus();
}