Web Program (ICT)
Web Program (ICT)
WEB
admin
[Link]
DEGREE COLLEGE GUNTUR
A
UNIT I
Internet Language, Understanding HTML, HTML document structure, Create a Web Page, Publishing
HTML Pages, Tags in HTML, title tag, Text Alignment tags, Text Formatting tags, heading tags, horizontal
rule tag, paragraph tag, break [Link] Lists - Ordered List, Unordered List & Definition List – Using
colors – Using Images
UNIT II
Horizontal Rule Tag - HTML Tables – Nested Tables - Hyperlinks: Textual, Graphical Links to sections –
Multimedia Objects – Frames – Nested Frames – Forms – Form Controls: textbox, password, checkbox,
radio button, select, text area - Processing of forms
UNIT III
JavaScript- Introduction, simple programming, Obtaining User Input with prompt Dialogs, Operators
(arithmetic, Decision making, assignment, logical, increment and decrement) Control Structures - if…
else selection statement, while, do… while repetitions statement, for statement, switch statement,
break and continue statements.
UNIT IV
Functions – program modules in JavaScript, programmer defined functions, function definition, scope
rules, global functions, and recursion JavaScript: Arrays, declaring arrays, accessing elements of an array.
UNIT V
Cascading Style Sheets: Introduction – Using Styles: As an attribute, tag & external file –Defining your
own styles Properties and values: properties related to Fonts, Backgrounds & colors, text, boxes &
borders Formatting blocks of information: Classes - Divisions – Spans - Layers with suitable examples.
Q) EXPLAIN INTERNET LANGUAGE ?
"Internet Language" refers to a style of communication that has evolved uniquely in online
communities. It's a blend of words, symbols, and cultural references that convey emotions, ideas,
and humor efficiently. Here are some key elements:
• Emoticons: Text-based symbols expressing emotions, like :-) for a smile or :( for a
frown.
• Emojis: Colorful symbols representing emotions, objects, and ideas ( , , ). They
add tone and context, which can be difficult to convey in text alone.
3. Memes
• Memes are images, videos, or phrases with cultural or humorous significance. They are
often shared, remixed, and adapted, creating in-jokes within communities.
4. Leetspeak (1337)
• Leetspeak is a playful way of writing words with numbers and symbols, popular in
hacker culture and gaming communities. For example, "leet" is written as "1337" by
replacing letters with numbers that resemble them.
5. Shorthand Expressions
6. Typing Quirks
• Some users type in all lowercase for a casual, understated feel or use deliberate
misspellings like "thx" for "thanks" or "u" for "you."
• Reaction GIFs or short animations express emotions or reactions visually. For instance, a
GIF of someone laughing can be used instead of typing "LOL."
• Hashtags (e.g., #TBT for "Throwback Thursday") organize topics and start conversations
across social media. They allow users to join trending topics and stay connected to
community discussions.
• Mock syntax includes asterisks for actions (e.g., sigh), or ALL CAPS and repeated
letters for emphasis (e.g., "NOOOO!"). These add a layer of personality or tone.
The Internet is a global phenomenon which can provide documents from servers
across the world to browser clients which can be in any location. Finally HTML is not really
very complicated although the creators of WYSIWYG (what you see is what you get)
authoring tools would like you to think that it is.
HTML was developed by Tim Berners Lee. He worked at CERN the European center
for practical physics. HTML is an application of something called SGML (standardized general
markup language). In 1960’s Charles Gold Farb, Adward Mosher and Raymond Lorie
at IBM created a general markup language.
In 1970’s the use of SGML in US department of Defense the DOD being swamped
by electronic documentation.
3 save the file by selecting the required drive and folder with html or htm extention
Or
Q. What are the HTML tags? How do the tags that switch a format on differ from
those which switch it off?
In HTML formatting is specified by using tags. The tags is format name surrounded
by angle brackets (< >). End tags which switch a format off also contain forward slash.
HTML tags can be 2 types. 1 paired tags <i> </i> 2) unpaired tags
<br>,<hr> these tags does not required any companion tag.
Features of HTML
1) It is a very easy and simple language. It can be easily understood and modified.
2) It is very easy to make effective presentation with HTML because it has a lot of
formatting tags.
3) It is a markup language so it provides a flexible way to design web pages along with the
text.
4) It facilitates programmers to add link on the web pages (by html anchor tag) , so it
enhances the interest
Macintosh etc.
6) It facilitates the programmer to add Graphics, Videos, and Sound to the web pages which
makes it more
Advantages of HTML:
Disadvantages of HTML:
1. It can create only static and plain pages so if we need dynamic pages then HTML is not
useful.
2. Need to write lot of code for making simple webpage.
4. If we need to write long code for making a webpage then it produces some complexity
<html>
<head>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph</p>
</body>
</html>
• The text between <html> and </html> describes the web page
• The text between <title> and </title> describes the title of your document. The title
is displayed in your browser’s caption.
• The text between <body> and </body> is the visible page content
• The text between <h1> and </h1> is displayed as a heading
• The text between <p> and </p> is displayed as a paragraph
The BODY element contains the document content, i.e. the information that is shown in the
browser's window.
BODY takes a number of attributes for specifying the background and colors of the
document on visual browsers.
Syntax:
<BODY
TEXT="color"
BGCOLOR="color"
BACKGROUND="URI"
LINK="color"
ALINK="color"
VLINK="color"
Height/width
Scroll
Right/left>
.....
</BODY>
Attribute Description
VLINK="color" Specifies the visited link color for the [Link] color
The comment tag is used to insert a comment in the HTML source code. A comment will be ignored by the
browser. You can use comments to explain your code, which can help you when you edit the source code at a later
date.
Note that you need an exclamation point after the opening bracket, but not before the closing bracket.
The purpose of comments is:
Q. What is the difference between <title> </title> and <h1> </h1> tags.
If you align a paragraph either to right or center of the screen always specify that
the next paragraph is aligned to the left. Not all browsers automatically return to the default
value.
In fact HTML has 6 levels of headings starting from <h1> to <h6>. The largest
heading is <h1> which should be used for main titles often these will be the same as the
title of the document as given in the <head> section of the page. Use <h2> and <h3> for
sub sessions of the document.
Syntax:
<title> tag is used in all HTML documents have just one title which is displayed at
the top of the browser window.
The end tag for P is optional when the paragraph is followed by another paragraph. If </P>
is omitted, the paragraph is not followed by a blank line.
Creating a simple web page involves writing HTML (HyperText Markup Language) and CSS
(Cascading Style Sheets). HTML provides the structure and content, while CSS handles the
styling. Here’s a step-by-step guide to creating a basic web page:
• Text Editor: You can use any text editor like Visual Studio Code, Sublime Text, Atom,
or Notepad++.
• Browser: To preview your web page, use any modern web browser (like Chrome,
Firefox, or Edge).
• Create a new file and name it [Link]. The .html extension tells the computer that
this is an HTML document.
• Open [Link] in your text editor and add the following basic HTML structure:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First Web Page</title>
<link rel="stylesheet" href="[Link]">
</head>
<body>
<header>
<h1>Welcome to My Web Page</h1>
<p>This is a simple web page created with HTML and CSS.</p>
</header>
<main>
<section>
<h2>About Me</h2>
<p>This is a short paragraph about me. I love coding and creating
new things on the web!</p>
</section>
<section>
<h2>My Interests</h2>
<ul>
<li>Programming</li>
<li>Web Design</li>
<li>Traveling</li>
</ul>
</section>
</main>
<footer>
<p>© 2023 My Web Page</p>
</footer>
</body>
</html>
• Create another file named [Link] in the same folder as your HTML file. Add some
CSS to style your page:
/* Basic Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Body Styling */
body {
font-family: Arial, sans-serif;
line-height: 1.6;
background-color: #f4f4f9;
color: #333;
margin: 20px;
}
/* Header Styling */
header {
background-color: #333;
color: #fff;
padding: 1rem;
text-align: center;
}
section {
margin-bottom: 20px;
}
h2 {
color: #333;
margin-bottom: 10px;
}
/* Footer Styling */
footer {
background-color: #333;
color: #fff;
text-align: center;
padding: 10px 0;
}
• Make sure the CSS file is linked in the <head> section of your HTML document:
• Locate [Link] in your file explorer, right-click on it, and open it in a browser. You
should see your basic web page with HTML content styled by CSS.
• Try adding more HTML elements (like images, tables, or links) and styling them with
CSS. Experiment with color schemes, fonts, and layouts!
This approach introduces the essentials for creating a simple static web page. For interactive or
dynamic content, you can eventually add JavaScript.
Publishing HTML pages online allows anyone to access your web page via a web browser.
Here’s a step-by-step guide to publishing your HTML pages:
• Free Hosting Options: Good for beginners, includes GitHub Pages, Netlify, and
Firebase.
• Paid Hosting Options: Offers more control and customization, includes Bluehost,
HostGator, or SiteGround.
• Static Site Hosts: Services like GitHub Pages, Netlify, or Vercel are particularly good
for HTML/CSS/JavaScript projects and are often free for basic use.
2. Prepare Your Files
• Make sure all your files are in a single folder with a clear structure. For example:
my-website/
├── [Link]
├── [Link]
├── [Link]
└── images/
1. Sign up for a paid hosting service and choose a domain name (or use one they provide).
2. Access the cPanel or FTP option to upload your files.
3. Upload your files to the public_html directory.
4. Your site will be available at your domain (e.g., [Link]
• FTP (File Transfer Protocol) is a way to manually upload files to a server. You can use
software like FileZilla to connect to your host:
o Open FileZilla, enter the FTP details (provided by your hosting provider), and log
in.
o Drag your site files into the public_html directory on the server.
• Anytime you want to make changes, just edit the files locally and upload them again to
replace the old files.
• GitHub Pages and Netlify update your live site every time you commit changes, making
it easy to maintain.
This should get your HTML pages online and accessible to anyone with the link!
<FONT
COLOR="color"
FACE="font_name"
SIZE="size">
.....
</FONT>
Attribute Description
Example 1
SIZE=1
SIZE=4
SIZE=7
<HTML>
<HEAD>
</HEAD>
<BODY>
<BASEFONT SIZE=1>SIZE=1
<BR>
<BASEFONT SIZE=4>SIZE=4
<BR>
<BASEFONT SIZE=7>SIZE=7
</BODY>
</HTML>
Q) Explain Some more text formatting tags are
HTML Formatting Elements
Formatting elements were designed to display special types of text:
<b> - Bold text
<strong> - Important text
<i> - Italic text
<em> - Emphasized text
<mark> - Marked text
<small> - Smaller text
<del> - Deleted text
<ins> - Inserted text
<sub> - Subscript text
<sup> - Superscript text
<ubr>,<center>,<strong>,<tt>,<marquee>,<hr>
<strike>,<sup>,<sub>,<blink>,<bgsound>,<big>,<em>
Q. Explain <br> tag and <pre> tag and explain about escape
sequence characters.
<br> tag forces a line break within a passage of a text where a paragraph
is not desirable.
Inside a <pre> tag the text is only wrapped when the source has a line
break and tabs or multiple white spaces are not converted to a single space.
Example 6
<HTML>
<HEAD>
</HEAD>
<BODY>
<PRE>
This
is
a
preformatted
text.
3) html colors?
HTML Colors
HTML colors are specified with predefined color names, or with RGB, HEX
HSL stands for hue, saturation, and lightness.
HSLA color values are an extension of HSL with an Alpha channel (opacity).
Text Color
<h1 style="color:Tomato;">Hello World</h1>
<p style="color:DodgerBlue;">Lorem ipsum...</p>
<p style="color:MediumSeaGreen;">Ut wisi enim...</p>
4 HTML Quotation
The HTML <q> tag defines a short quotation.
<p>PYK's: <q>SUN GIVES 12 HOURS BUT KUMAR METERIALS GIVES
CHANGE YOUR LIFE.</q></p>
The HTML <address> tag defines the contact information for the author/owner
of a document or an article.
The text in the <address> element usually renders in italic, and browsers will
always add a line break before and after the <address> element.
Example
<address>
[Link].<br>
Visit us at:<br>
[Link]<br>
GUNTUR<br>
A.P
</address>
---> .GIF - short for Graphics Interchange Format and pronounced jiff or giff
(hard g);
---> .JPEG - short for Joint Photographic Experts Group and pronounced jay-
peg.
GIF supports color and various resolutions. It also includes data compression,
making it especially effective for scanned photos.
<IMG
ALIGN="left"|"right"|"top"|"middle"|"bottom"
ALT="text"
BORDER="pixels"
HEIGHT="height"
WIDTH="width"
HSPACE="pixels"
VSPACE="pixels"
SRC="URI">
Attributes
Attribute Description
Example:
<HTML>
<HEAD> </HEAD>
<BODY> This is a text that can be replaced by any sequence of symbols.
<IMG SRC="[Link]" WIDTH="80" HEIGHT="80" BORDER="2"
ALIGN="left">
If you type sequences of symbols, don't forget to leave spaces between
"words".
</BODY>
</HTML>
Ordered Lists:
The OL element defines an ordered list. The element contains one or
more LI elements that define the actual items of the list.
Syntax
<OL
START="number"
TYPE="A"|"a"|"I"|"i"|"1">
.....
</OL>
Attribute Description
START="number" Specifies the starting number of the list.
Un ordered Lists:
The UL element defines an unordered list. The element contains one or
more LI elements that define the actual items of the list.
Syntax
<UL TYPE="disc"|"circle"|square">
.....
</UL>
Attributes
Attribute Description
List Items
The LI element defines a list item. The element must be contained within
OL or UL.
Syntax
<LI
TYPE="disc"|"circle"|"square"|"A"|"a"|"I"|"i"|"1"
VALUE="number" >
.....
</LI>
Definition Lists
A definition list is not a list of items. This is a list of terms and
explanation of the terms.
A definition list starts with the <dl> tag. Each definition-list term starts
with the <dt> tag. Each definition-list definition starts with the <dd> tag.
<dl>
<dt>Coffee</dt>
<dd>Black hot drink</dd>
<dt>Milk</dt>
<dd>White cold drink</dd>
</dl>
Coffee
Black hot drink
Milk
White cold drink
Inside a definition-list definition (the <dd> tag) you can put paragraphs,
line breaks, images, links, other lists, etc.
Example: creating an ordered list.
<HTML>
<HEAD>
</HEAD>
<BODY>
<OL START="1" TYPE="1">
<LI>Math's</LI>
<LI>Chemistry</LI>
<LI>Biology</LI>
<LI>Geography</LI>
</OL>
</BODY>
</HTML>
• Rivers
• Seas
<HTML>
<HEAD>
</HEAD>
<BODY>
<UL TYPE="disc">
<LI>Rivers</LI>
<LI>Seas</LI>
</UL>
</BODY>
</HTML>
<!DOCTYPE html>
<html>
<body>
<hr>
<p>With CSS:</p>
<hr style="height:9px;border-width:5;color:BLUE;background-color:RED">
</body>
</html>
UNIT-II
Q) EXPLAIN TABLES IN HTML?
Tables have two uses. Structuring piece of information and structuring the
whole web page.
<TABLE
ALIGN="left"|"center|"right"
BGCOLOR="color"
BORDER="pixels"
CELLPADDING="pixels"
CELLSPACING="pixels"
HEIGHT="height"
WIDTH="width">
.....
</TABLE>
Attributes
Attribute Description
"left"
Specifies the horizontal alignment of the table.
ALIGN= "center"
The default is left.
"right"
Table elements:
Tables are defined with the <table> tag. A table is divided into rows (with the
<tr> tag), and each row is divided into data cells (with the <td> tag). The letters
td stands for "table data," which is the content of a data cell.<caption> provide
a visual caption for the table.<thead> logically groups header elements in a
table.<tbody> logically groups elements that make the body of the table
content.<tfoot> logically groups elements that comprise the footer area of
tables content. A data cell can contain text, images, lists, paragraphs, forms,
horizontal rules, tables, etc.
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
Example:
<HTML>
<HEAD>
</HEAD>
<BODY>
<TABLE ALIGN="center" BORDER="2" BGCOLOR="red" CELLPADDING="5"
CELLSPACING="0">
<CAPTION><B>Table</B></CAPTION>
<TR ALIGN="center">
<TH COLSPAN="2">School</TH>
</TR>
<TR ALIGN="center" BGCOLOR="green">
<TH BGCOLOR="aqua">Name of student</TH>
<TH>Grade</TH>
</TR>
<TR ALIGN="left" BGCOLOR="yellow">
<TD>Steve</TD>
<TD>K-11</TD>
</TR>
<TR ALIGN="right">
<TD>Peter</TD>
<TD>K-12</TD>
</TR>
</TABLE>
</BODY>
</HTML>
Colspan: This is used to merge the selected number of columns in the given
row.
Example:
<table border=5 cellpadding=10 cellspacing=10>
<tr><th colspan=3>tic tac toe</th></tr>
<tr><td>x<td>0<td>x</tr>
<tr><td>x<td>0<td>x</tr>
<tr><td>x<td>0<td>x</tr>
<table>
The powerful and flexible of HTML comes from the simple method it uses to link
documents together. Links should be used freely within documents where they either added
to the understanding of the work or can be used to reduce download times.
HTML uses the <a> (anchor) tag to create a link to another document.
An anchor can point to any resource on the Web: an HTML page, an image, a sound file, a movie, etc.
The syntax of creating an anchor:
The <a> tag is used to create an anchor to link from, the href attribute is used to address the document to link to, and
the words between the open and close of the anchor tag will be displayed as a hyperlink. url means uniform resource
locator.
<a href="[Link]
target="_blank">Visit students blogs!</a>
The name attribute is used to create a named anchor. The name of the anchor can be any text you care to
use.
<a href="[Link]
Jump to the Useful Tips Section</a>
A hyperlink to the Useful Tips Section from WITHIN the file "html_links.asp" will look like this:
Attribute Description
Relative path url: this is used if the file is located in the same folder where the html
document is stored
This is used if the file is located on a remote site outside the folder that contains the html
document.
Eg:
Example:
Define the following list, in which items are links to files: [Link], [Link],
[Link], [Link]
Use relative URI's.
<HTML>
<HEAD>
</HEAD>
<BODY>
<UL>
<B>HTML TUTORIAL</B><BR>
<LI><A HREF="[Link]">Lesson1</A></LI>
<LI><A HREF="[Link]">Lesson2</A></LI>
<LI><A HREF="[Link]">Lesson3</A></LI>
<LI><A HREF="[Link]">Lesson4</A></LI>
</UL>
</BODY>
</HTML>
Example:
Define two links to files [Link] and [Link], and one to the non-existing file
[Link]
Lesson8
Lesson9
Lesson10
Use the BODY attributes to define colors for links, visited links and active link.
<HTML>
<HEAD>
</HEAD>
<BODY LINK="purple" VLINK="blue" ALINK="red">
<A HREF="[Link]">Lesson8</A>
<BR>
<A HREF="[Link]">Lesson9</A>
<BR>
<A HREF="[Link]">Lesson10</A>
<BR>
</BODY>
</HTML>
of hyperlinks.
file or document.
When adding a text or image hyperlink that moves off your site, have it open in a new
window. This allows visitors to easily come back to your site without having to use the back
button on their browser. Text or image hyperlinks can also be used to move between pages
within a site.
Syntax
<FRAMESET
COLS="list"
ROWS="list"
BORDER="pixels"
BORDERCOLOR="color"
FRAMEBORDER="yes"|"no"
FRAMESPACING="pixels">
.....
</FRAMESET>
Attributes
Attribute Description
Syntax
<FRAME
NAME="name"
MARGINHEIGHT="pixels"
MARGINWIDTH="pixels"
BORDERCOLOR="color"
FRAMEBORDER="yes"|"no"
NORESIZE
SCROLLING="yes"|"no"|"auto"
SRC="URI">
Attributes
Attribute Description
<HTML>
<HEAD>
</HEAD>
<FRAMESET ROWS="40%,*">
<FRAME SRC="[Link]">
<FRAME SRC="[Link]">
</FRAMESET>
</HTML>
Example:
<HTML>
<HEAD>
</HEAD>
<FRAMESET ROWS="40%,*" BORDER="10" BORDERCOLOR="red">
<FRAME SRC="[Link]" MARGINHEIGHT="50"
MARGINWIDTH="50">
<FRAME SRC="[Link]">
</FRAMESET>
</HTML>
A hyper link which loads a document in a frame is created , the file references
in the hyperlink will be opened and will replace the current document that is in
the frame. This is done by the name attribute of the <frame></frme> [Link]
name is one of the parameter.
Ex
<a href=”[Link]” target=”second”>kumar</a>
Here the file is called [Link] is loaded into the frame names [Link]
the hyper link clicked [Link](where is name is targeted location)
Q)EXPLAIN FORMS IN HTML?
The form can contain interface elements such as text fields, buttons,
checkboxes, radio buttons, and selection lists that let users enter text and
make choices, and then submit the form by clicking a "Submit" button.
The form can be submitted to a program on server or to an E-mail address.
Syntax:
<FORM ACTION="action" METHOD="GET"|"POST">
</FORM>
Attributes
Attribute Description
"GET"
METHOD= Specifies how the form input is sent to the server.
"POST"
The INPUT element defines a form control for the user to enter input.
INPUT must be contained within FORM.
Syntax
<INPUT
NAME="name"
SIZE="number"
TYPE="text|checkbox|radio|submit|reset"
VALUE="value"
CHECKED>
Attributes
Attribute Description
Attribute Description
VALUE="value"
provides the text of the button for reset and
submit controls;
CHECKED Specifies
The SELECT element defines a form control for the multiple choice selection of
options on the screen.
SELECT must be contained within FORM.
Syntax
<SELECT
NAME="name"
SIZE="number"
MULTIPLE>
.....
</SELECT>
Attributes
Attribute Description
Syntax
Attributes
Attribute Description
Syntax
<TEXTAREA
NAME="name"
COLS="number"
ROWS="number">
.....
</TEXTAREA>
Attributes
Attribute Description
Example:
<HTML>
<HEAD>
</HEAD>
<BODY>
<FORM METHOD="POST" ACTION="[Link]
<H4>FORM</H4>
Enter your name here
<INPUT TYPE="text" NAME="var1" SIZE="30" VALUE="">
<BR><BR>
<B>Are you a student?</B>
<INPUT TYPE="checkbox" NAME="var2">
<BR><BR>
<B>How old are you?</B>
<BR>
<INPUT TYPE="radio" NAME="var3" VALUE="r1">10 - 15
<BR>
<INPUT TYPE="radio" NAME="var3" VALUE="r2">16 - 20
<BR>
<INPUT TYPE="radio" NAME="var3" VALUE="r3">21 - 25
<BR><BR>
<B>Where are you from?</B>
<BR>
<SELECT NAME="var6" SIZE="1">
<OPTION VALUE="BG">Bulgaria
<OPTION VALUE="UK">United Kingdom
<OPTION VALUE="USA" SELECTED>USA
</SELECT>
<BR><BR>
<B>Your comment:</B>
<BR>
<TEXTAREA NAME="var7" COLS="30" ROWS="6">
</TEXTAREA>
<BR><BR>
<INPUT TYPE="submit" NAME="var4" VALUE="Send">
<INPUT TYPE="reset" NAME="var5" VALUE="Clear">
</FORM>
</BODY>
</HTML>
UNIT III
Q) INTRODUCTION OF JAVA SCRIPT
JavaScript is a versatile, high-level programming language primarily used to make web pages
interactive and dynamic. Created in 1995 by Brendan Eich, it initially started as a small scripting
language to add simple effects to web pages, but it has since evolved into one of the most
important technologies of the web. Alongside HTML and CSS, JavaScript forms the foundation
of web development, enabling websites to be not just static displays of information but
interactive, responsive applications.
When you write JavaScript code in a .js file or inline within HTML, the browser’s JavaScript
engine (such as V8 in Chrome or SpiderMonkey in Firefox) interprets and executes the code.
This code can manipulate the content, structure, and appearance of the page by interacting with
the HTML and CSS.
html
Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<title>JavaScript Example</title>
</head>
<body>
<h1>Welcome to JavaScript!</h1>
<button onclick="showMessage()">Click Me</button>
<script>
function showMessage() {
alert("Hello! You clicked the button.");
}
</script>
</body>
</html>
In this example:
• When the user clicks the "Click Me" button, the showMessage function runs, displaying an alert
with a message.
Today, JavaScript is not only used for front-end development but also on the server side through
[Link]. With frameworks like React, Angular, and Vue, JavaScript is central to building
single-page applications (SPAs), which allow users to interact with different views in a single
web page without reloading.
JavaScript has become indispensable for modern web development due to its interactivity, speed,
and ease of use. Its ability to provide a seamless, engaging user experience makes it a key
technology in building applications that are fast, responsive, and feature-rich.
Whether you are building a simple interactive website or a full-scale web application, JavaScript
is an essential language to learn and use in web development.
Q. What are the key points that you need to apply in java script. Outline the
structure of java script program.
<html>
<head>
<script language="javascript">
<!--
function sai()
function ram()
-->
</script>
</head>
</body>
</html>
Note: Browsers that do not support JavaScript, will display JavaScript as page content. To prevent them from doing
this, and as a part of the JavaScript standard, the HTML comment tag should be used to "hide" the JavaScript. Just
add an HTML comment tag <!-- before the first JavaScript statement, and a --> (end of comment) after the last
JavaScript statement
Java Scripts in the body section will be executed WHILE the page loads.
Q. What is the difference between a variable and value, how should variables be
named. How Variables used in java script.
These are data items that you can manipulate as the program runs. A variable is a
named value that used in your programs like x=5. Here variable name is x which is
set to the value 5. Global variables and local variables
Ex:
Var money;
Var name;
Var age=40;
Rules:
<html>
<head>
</head>
<body>
<!--
[Link]();
-->
</script>
</body>
</html>
Q. What data types does java script use?
1. Numerical data types: These are the basic numbers it can include all the integers,
fractions and expression data.
2. String data type: These are collection of characters or a single character in the
double quotes. The string data type can also store numbers represented in the form
of string using double quotes.
String s1=”1234”;
3. Boolean data type: Boolean variables hold the values “ true” and “false”. These are
used a lot in programming to hold results of conditional text.
4. Null data types: This is used when you don’t know something. A Null value means one
that has been decided.
These messages can be introduced in our scripts by using three predefined functions
of methods. These are given below:
Prompt(“string”, “string”)
Confirm(“string”)
Alert(string”)
Conditional Statements
Very often when you write code, you want to perform different actions for different decisions. You can use
conditional statements in your code to do this.
In JavaScript we have the following conditional statements:
• if statement - use this statement to execute some code only if a specified condition
is true
• if...else statement - use this statement to execute some code if the condition is
true and another code if the condition is false
• if...else if....else statement - use this statement to select one of many blocks of
code to be executed
• switch statement - use this statement to select one of many blocks of code to be
executed
If Statement
Use the if statement to execute some code only if a specified condition is true.
Syntax
if (condition)
{
code to be executed if condition is true
}
Example:
<script type="text/javascript">
//Write a "Good morning" greeting if
//the time is less than 10
if (time<10)
{
[Link]("<b>Good morning</b>");
}
</script>
If...else if...else Statement
Use the if....else if...else statement to select one of several blocks of code to be executed.
Syntax
if (condition1)
{
code to be executed if condition1 is true
}
else if (condition2)
{
code to be executed if condition2 is true
}
else
{
code to be executed if condition1 and condition2 are not true
}
Use the switch statement to select one of many blocks of code to be executed.
Syntax
switch(n)
{
case 1:
execute code block 1
break;
case 2:
execute code block 2
break;
default:
code to be executed if n is different from case 1 and 2
}
Example
<script type="text/javascript">
//You will receive a different greeting based
//on what day it is. Note that Sunday=0,
//Monday=1, Tuesday=2, etc.
JavaScript Loops
Syntax
for (var=startvalue;var<=endvalue;var=var+increment)
{
code to be executed
}
Syntax
while (var<=endvalue)
{
code to be executed
}
Example
<html>
<body>
<script type="text/javascript">
var i=0;
while (i<=5)
{
[Link]("The number is " + i);
[Link]("<br />");
i++;
}
</script>
</body>
</html>
Continue
<html>
<body>
<h2>JavaScript Loops</h2>
<p id="demo"></p>
<script>
if (i === 3) { continue; }
[Link]("demo").innerHTML = text;
</script>
</body>
</html>
= x=y x=5
Logical Operators
Logical operators are used to determine the logic between variables or values.
Given that x=6 and y=3, the table below explains the logical operators:
Conditional Operator
JavaScript also contains a conditional operator that assigns a value to a variable based on some condition.
Syntax
variablename=(condition)?value1:value2
Example
UNIT IV
Q. Explain arrays in java script.
What is an Array?
An array is a special variable, which can hold more than one value, at a time.
An array can hold all your variable values under a single name. And you can access the values by referring to the
array name.
Each element in the array has its own ID so that it can be easily accessed.
Create an Array
The following code creates an Array object called myCars:
var myCars=new Array();
There are two ways of adding values to an array (you can add as many values as you need to define as many
variables you require).
1:
var myCars=new Array();
myCars[0]="Saab";
myCars[1]="Volvo";
myCars[2]="BMW";
2:
var myCars=new Array("Saab","Volvo","BMW");
Access an Array
You can refer to a particular element in an array by referring to the name of the array and the index number. The
index number starts at 0.
The following code line:
[Link](myCars[0]);
Saab
[Link](myCars[0]);
Opel
constructor Returns a reference to the array function that created the object
index
input
join() Puts all the elements of an array into a string. The elements are
separated by a specified delimiter
push() Adds one or more elements to the end of an array and returns
the new length
A function is a piece of code that performs a specific task. Java script has a lot of
functions built into the language. Once you have created some functions you need to know
how to use them, this is done by calling the function.
Function name(parameters)
Body of function
Functions are defined using the function keyword. The name can be any combination
of digits, letters of underscore. The function receives value as a parameter.
Function call:
In java script parameters are passed as arrays. Every function has two properties
that can be used to find information about the parameters.
Variables are declared in a function are local. You can’t get their value outside the
function unless you pass them around as parameters. That mechanism is provided by the
return statement.
Example:
Function sai(number)
{
Return answer;
Var x=sai(32);
Scoping rules:
Programming languages usually impose rules, called scoping, which determine how a
variable can be accessed. In java script variables can be either local or global.
Global:
Global scoping means that a variable is available to all parts of the program. Such
variables are declared outside the function and are usually used to hold static data.
Local:
Local variables are declared inside a function. They can only be used by that
function.
Q) recursion JavaScript
Recursion in JavaScript is a programming technique where a function calls itself to solve smaller
instances of a problem until it reaches a base case, which stops further recursive calls. Recursion
is commonly used for tasks that can be divided into similar, smaller sub-tasks.
1. Base Case: This is the condition under which the recursive function stops calling itself. Without a
base case, the function would call itself indefinitely, leading to a stack overflow.
2. Recursive Case: This is the part of the function where the function calls itself with a modified
argument to gradually approach the base case.
Example: Factorial Calculation
The factorial of a number nnn (written as n!n!n!) is the product of all positive integers from 1 to
nnn. For example, 5!=5×4×3×2×1=1205! = 5 \times 4 \times 3 \times 2 \times 1 =
1205!=5×4×3×2×1=120.
javascript
Copy code
function factorial(n) {
// Base case: when n is 0, return 1
if (n === 0) {
return 1;
}
// Recursive case: multiply n by factorial of (n - 1)
else {
return n * factorial(n - 1);
}
}
1. Base Case: When nnn reaches 0, the function returns 1 (since 0!=10! = 10!=1).
2. Recursive Case: If nnn is greater than 0, the function returns n×factorial(n−1)n \times
\text{factorial}(n - 1)n×factorial(n−1).
The function calls itself with progressively smaller values of nnn until nnn reaches 0, at which
point the recursion stops.
UNIT V
Q)What do web designers mean when they are talk about a style?
A style is simply a set of formatting instructions that can be applied to a
piece of text. Styles define how to display HTML elements. There are three
mechanisms by which we can apply styles to our HTML documents.
Styles can be cascaded. This means the formats override any which were
defined or included earlier in the document.
The page may be viewed on a television screen, a computer screen or
mobile phones, any of which may show images, text, tables, or a mixture of
them all. Straightforward HTML does not have the facilities that are needed to
manage with this variety, but style sheets provide them.
Example:
<html>
<head>
<title> simple style sheet </title>
<style>
<!--
h1
{ color: red; border: thin groove; text-align: center;}
-->
</style>
</head>
<body>
<h1> simple style sheet </h1>
<p> The first paragraph is left </p>
<p style = "margin-left:10%; border: ridge ; background: #ffffcc">
but this paragraph undergoes
</p>
<p> we finish with un altered paragraph </p>
</body>
</html>
The syntax of the style definition changes when it is done inside an html tag.
The definition becomes an attribute, named style of the tag.
Rules:
A style rule has two parts. Selector and set of declarations:
The selector is used to create link between the rule and html tag. The
declaration has two parts. A Property and a value: declaration must be
separated using colons and terminated using semicolons.
Selector {property: value; property: value; ……….}
If you miss the colon or fail to put the semi colon between the declarations, the
style can not be processed.
Classes:
This method similar to style. This is fine if you want every paragraph equally
intended or every level one heading in the same font if you only want to apply a style to
some paragraphs, for instance you have to use classes.
Syntax:
Ex:
1. Body {color:black}
3. H1,h2,h3,h4,h5,h6
Color: green;
Font-family:arial
Class selector
With the class selector you can define different styles for the same type of HTML
element.
Ex:
[Link] { text-align:right}
[Link] {text-align:center}
Element wise where the name of the element is given before the class name
Ex:
p.c1{background:blue}
universal use for multiple elements declared only with .symbol before the class name
ex:
<style type=”text/css”>
[Link]{background-color:blue}
.red{background-color:red}
.yellow{background-color:yellow}
</style>
Anonymous classes:
Some times you want to apply a piece of formatting to many different elements
within a page but not necessarily to the entire page. Cascading style sheets provides a way
of defining styles within reusable classes in the example.
.center { text-align:center}
.mystyle
font-family: verdana;
font-size:4;
font-color: magenta
Example:
<html>
<head>
<style>
<!--
.sai {text-align:center}
-->
</style>
</head>
<body>
</body>
</html>
Or
Q. Describe the different ways that styles can be added to a web page.
1. External
2. Internal(embedded)
3. Inline
4 imported style sheets
<head>
<link rel="stylesheet" type="text/css"
href="[Link]">
</head>
The href is hyper link to your style sheet. Rel tells the browser what type of link you
are using. And the type statement gives the relevant MIME type, it is optional. An external
style sheet can be written in any text editor. The file should not contain any html tags. Your
style sheet should be saved with a .css extension.
Internal style sheets
Internal styles are the styles declared in head section of a web page. The styles are
declared here using <style> and </style> tag.
Ex:
<head>
<style type=”css/text”>
Hr {color: sienna}
P {margin-left: 20px}
</style>
</head>
Inline styles
The inline styles are another way of style declaration for the basic HTML tags. These
inline styles are declared itself in the tag declaration as a tag argument named “style” for
the tag.
<p style=”color: pink; margin-left: 15px”> This is sample paragraph applying inline styles
</p>
An imported style sheet is a sheet that can be imported to or combined with another style
sheet. This allows creating one main sheet containing declarations that apply to the whole
[Link] the @ import notation in the style element.
Ex:
File 1: [Link]
<style>
H1{font-style:italic;color:red}
P{background:yellow}
</style>
File 2: [Link]
<style>
@import url([Link]);
</style>
File 3:[Link]
<html>
<head>
</head>
<body>
Sairam
</body>
</html>
Cascading (Inheritance)
Multiple styles declared in a web page will cascade into one. The cascading order for
more than one style specified to an HTML element is below. Generally all styles will be
cascaded into a new virtual style sheet.
1. Browser default
2. External style sheet
3. Internal styles
4. Inline styles
Q) EXPLAIN BACK
GROUND,BORDERS,MARGING,PADDING?
The CSS background properties are used to add background effects for
elements.
body {
background-color: lightblue;
}
1 background color for any HTML elements:
Example
Here, the <h1>, <p>, and <div> elements will have different background colors:
h1 {
background-color: green;
}
div {
background-color: lightblue;
}
p{
background-color: yellow;
}
2 The background-image property specifies an image to use as the
background of an element.
BORDERS
[Link] {
border-style: solid;
border-color: green;
}
[Link] {
border-style: dotted;
border-color: blue;
}
</style>
</head>
<body>
</body>
</html>
Border - Shorthand Property
Like you saw in the previous page, there are many properties to consider when
dealing with borders.
To shorten the code, it is also possible to specify all the individual border
properties in one property.
The border property is a shorthand property for the following individual border
properties:
• border-width
• border-style (required)
• border-color
<html>
<head>
<style>
p{
border: 5px solid red;
}
</style>
</head>
<body>
CSS has properties for specifying the margin for each side of an element:
• margin-top
• margin-right
• margin-bottom
• margin-left
<html>
<head>
<style>
div {
border: 1px solid black;
margin-top: 100px;
margin-bottom: 100px;
margin-right: 150px;
margin-left: 80px;
background-color: lightblue;
}
</style>
</head>
<body>
<div>SAIRAM IS GOD.</div>
</body>
</html>
padding
CSS has properties for specifying the padding for each side of an element:
• padding-top
• padding-right
• padding-bottom
• padding-left
<html>
<head>
<style>
div {
border: 1px solid black;
background-color: lightblue;
padding-top: 50px;
padding-right: 30px;
padding-bottom: 50px;
padding-left: 80px;
}
</style>
</head>
<body>
</body>
</html>
CSS height and width Values
The height and width properties may have the following values:
• auto - This is default. The browser calculates the height and width
• length - Defines the height/width in px, cm, etc.
• % - Defines the height/width in percent of the containing block
• initial - Sets the height/width to its default value
• inherit - The height/width will be inherited from its parent value
<html>
<head>
<style>
div {
height: 200px;
width: 50%;
background-color: YELLOW;
}
</style>
</head>
<body>
<div>SAIRAM IS GOD</div>
</body>
</html>
Q) EXPLAIN TEXT IN CSS?
Text: The CSS text properties define the appearance of text:
Text Alignment
The text-align property is used to set the horizontal alignment of a text.
Text can be centered, or aligned to the left or right, or justified. When text-align
is set to "justify", each line is stretched so that every line has equal width, and
the left and right margins are straight (like in magazines and newspapers).
Example
h1 {text-align:center}
[Link] {text-align:right}
[Link] {text-align:justify}
Text Decoration
The text-decoration property is used to set or remove decorations from
text. The text-decoration property is mostly used to remove underlines from
links for design purposes.
Example
a {text-decoration:none}
h1 {text-decoration:overline}
h2 {text-decoration:line-through}
h3 {text-decoration:underline}
h4 {text-decoration:blink}
Text Transformation
The text-transform property is used to specify uppercase and lowercase
letters in a text. It can be used to turn everything into uppercase or lowercase
letters, or capitalize the first letter of each word.
Example
[Link] {text-transform:uppercase}
[Link] {text-transform:lowercase}
[Link] {text-transform:capitalize}
Text Indentation
The text-indentation property is used to specify the indentation of the first line
of a text.
Example
p {text-indent:50px}
• Margin - Clears an area around the border. The margin does not have a
background color, and it is completely transparent
• Border - A border that lies around the padding and content. The border
is affected by the background color of the box
• Padding - Clears an area around the content. The padding is affected by
the background color of the box
• Content - The content of the box, where text and images appear
In order to set the width and height of an element correctly in all browsers, you
need to know how the box model works.
Width and Height of an Element
Important: When you specify the width and height properties of an
element with CSS, you are just setting the width and height of the content
area. To know the full size of the element, you must also add the padding,
border and margin. The total width of the element in the example below is
300px:
width:250px;
padding:10px;
border:5px solid gray;
margin:10px;
Font Family
The font family of a text is set with the font-family property. The font-
family property can hold several font names as a "fallback" system. If the
browser does not support the first font, it tries the next font.
Start with the font you want, and end with a generic family, to let the
browser pick a similar font in the generic family, if no other fonts are available.
Note: If the name of a font family is more than one word, it must be in
quotation marks, like font-family: "Times New Roman". More than one font
family is specified in a comma-separated list.
Example
p{font-family:"Times New Roman",Georgia,Serif}
Font Style
The font-style property is mostly used to specify italic text. This property
has three values:
• normal - The text is shown normally
• italic - The text is shown in italics
• oblique - The text is "leaning" (oblique is very similar to italic, but less
supported)
Example
[Link] {font-style:normal}
[Link] {font-style:italic}
[Link] {font-style:oblique}
Q. What is a layer, how are they described within the HTML code.
The page layout that a browser creates results from layering text and images on top
of each other. Use images as the backgrounds of their pages and then place further images
and text over them. Some of the powerful attributes in a DIV tag.
z-index: n –
The background image is placed first, with text and image on top of it.
The lowest layer appearing on top of the background has a z-index of 1. Many layers can
have same z-index value if you want to place them at the same level. If you number of
layers sequentially as you move up the stack you are unlikely to place more than about 20
layers before the screen becomes unmanageable.
Left: n
Top: n
You locate divisions around the screen by specifying the positions of their top left
corner. Default 0, 0.
Width: n
Height: n
Example:
<html>
<head>
</head>
<body>
<div style = "z-index:2; left:50px; top:250px; position: absolute; color: red; text:
white;
</div>
</div>
<div style = "z-index:4; left:10px; top:30px; width: 150px; position: absolute; color: black;
background-color: yellow; font-size: 18pt;">
</div>
<div style = "z-index:2; left:500px; top:300px; position: absolute; width: 25; color:
blue;
</div>
<hr>
</body>
</html>
Relative units:
Px:pixels
Absolute units:
In:size in inches
Q. Compare and contrast the use of DIV and [Link] Formatting blocks of
information?
DIVISIONS
<p>………..</p>
<h2>……..</h2>
<hr>
</div>
Spans:
The HMTL standard no longer supports the idea of modifying individual items in
place. A simple and effective model has been devised based around the span tag.
The DIV and SPAN tags are identical parameters. But the effects of those parameters are
altered by the context in which they are used. Each can have an ID so that it can be
identified by other elements on the page. It is not useful on static page of text but it is
useful in Dynamic HTML. Styles are applied to SPAN and DIV through either the class or
style parameters