Full Stack Development Lab Manual
Full Stack Development Lab Manual
Lab Manual
Sl. No List of Experiments Page no
1 Lists, Links and Images 4
(a) Write a HTML program, to explain the working of lists.
Note: It should have an ordered list, unordered list, nested
lists and ordered list in an unordered list and definition lists.
(b) Write a HTML program, to explain the working of
hyperlinks using tag and href, target Attributes.
(c) Create a HTML document that has your image and your
friend’s image with a specific height and width. Also when
clicked on the images it should navigate to their respective
profiles.
(d) Write a HTML program, in such a way that, rather than
placing large images on a page, the preferred technique is to
use thumbnails by setting the height and width parameters to
something like to 100*100 pixels. Each thumbnail image is
also a link to a full sized version of the image. Create an
image gallery using this technique.
2 HTML Tables, Forms and Frames 13
(a) Write a HTML program, to explain the working of tables.
(b) Write a HTML program, to explain the working of tables by
preparing a timetable.
(c) Write a HTML program, to explain the working of forms by
designing Registration form.
(d) Write a HTML program, to explain the working of frames,
such that page is to be divided into 3 parts on either
direction.
3 HTML 5 and Cascading Style Sheets, Types of CSS 20
(a) Write a HTML program, that makes use of <article>,<aside>,
<figure>, <figcaption>, <footer>, <header>, <main>, <nav>,
<section>, <div>, <span> tags.
(b) Write a HTML program, to embed audio and video into
HTML web page.
(c) Write a program to apply different types (or levels of styles
or style specification formats) - inline, internal, external
styles to HTML elements. (identify selector, property and
value).
4 Selector forms 38
(a) Write a program to apply different types of selector forms
(i) Simple selector (element, id, class, group, universal)
(ii) Combinator selector (descendant, child, adjacent
sibling, general sibling)
(iii) Pseudo-class selector
(iv) Pseudo-element selector
(v) Attribute selector
5 CSS with Color, Background, Font, Text and CSS Box Model 52
(a) Write a program to demonstrate the various ways you can
reference a color in CSS.
(b) Write a CSS rule that places a background image halfway
down the page, tilting it horizontally. The image should
remain in place when the user scrolls up or down.
(c) Write a program using the following terms related to CSS
font and text: i. font-size ii. font-weight iii. font-style
(d) Write a program, to explain the importance of CSS Box
model using [Link] ii. Border iii. Margin iv. padding
6 Applying JavaScript - internal and external, I/O, Type Conversion 61
(a) Write a program to embed internal and external JavaScript in
a web page.
(b) Write a program to explain the different ways for displaying
output.
(c) Write a program to explain the different ways for taking input.
(d) Create a webpage which uses prompt dialogue box to ask a
voter for his name and age. Display the information in table
format along with either the voter can vote or not.
7 Java Script Pre-defined and User-defined Objects
a. Write a program using document object properties and
methods.
b. Write a program using window object properties and methods.
c. Write a program using array object properties and methods.
d. Write a program using math object properties and methods.
e. Write a program using string object properties and methods.
f. Write a program using regex object properties and methods.
g. Write a program using date object properties and methods.
h. Write a program to explain user-defined object by using
properties, methods, accessors, constructors and display.
8 Java Script Conditional Statements and Loops
a. Write a program which asks the user to enter three integers,
obtains the numbers from the user and outputs HTML text that
displays the larger number followed by the words “LARGER
NUMBER” in an information message dialog. If the numbers
are equal, output HTML text as “EQUAL NUMBERS”.
b. Write a program to display week days using switch case.
c. Write a program to print 1 to 10 numbers using for, while and
do-while loops.
d. Write aprogram to print data in object using for-in, for-each
and for-of loops
e. Develop a program to determine whether a given number is an
‘ARMSTRONG NUMBER’ or not. [Eg: 153 is an Armstrong
number, since sum of the cube of the digits is equal to the
number i.e.,13 + 53+ 33 = 153]
f. Write a program to display the denomination of the amount
deposited in the bank in terms of 100’s, 50’s, 20’s, 10’s, 5’s,
2’s & 1’s.
9 Java Script Functions and Events
a. Design a appropriate function should be called to display
[Link] of that number
ii. Fibonacci series up to that number
iii. Prime numbers up to that number
iv. Is it palindrome or not
b. Design a HTML having a text box and four buttons named
Factorial, Fibonacci, Prime, and Palindrome. When a button is
pressed an appropriate function should be called to display
[Link] of that number
ii. Fibonacci series up to that number
iii. Prime numbers up to that number
iv. Is it palindrome or not
c. Write a program to validate the following fields in a registration
page
i. Name (start with alphabet and followed by alphanumeric
and the length should not be less than 6 characters)
ii. Mobile (only numbers and length 10 digits)
iii. E-mail (should contain format like
xxxxxxx@[Link])
Basic of HTML, CSS and Java Script
HTML: HTML stands for Hyper Text Markup Language. HTML is use for creating web
page. It describes the structure of a web page. It consists of a series of tags.
HTML Tags: HTML Tags is a keyword that tells a web browser how to format and display
content on a web page.
<html>
<head>
<tiltle> Page title </html>
</head>
<body>
<h1> It is used for heading </h1>
<p> It is used for paragraph </p>
</body>
</html>
Experiment 1
Lists, Links and Images
(a) Write a HTML program, to explain the working of lists. Note: It should have an
ordered list, unordered list, nested lists and ordered list in an unordered list and
definition lists.
(b) Write a HTML program, to explain the working of hyperlinks using tag and href,
target Attributes.
(c) Create a HTML document that has your image and your friend’s image with a
specific height and width. Also when clicked on the images it should navigate to
their respective profiles.
(d) Write a HTML program, in such a way that, rather than placing large images on a
page, the preferred technique is to use thumbnails by setting the height and width
parameters to something like to 100*100 pixels. Each thumbnail image is also a link
to a full sized version of the image. Create an image gallery using this technique.
Solution
(a) Write a HTML program, to explain the working of lists
List: A list in HTML is a way to group items together using tags. List is of 3 types.
Ordered list.
Unordered list.
Description list.
HTML List tag
[Link] Name of the Tag Representation of Description about Tag
tag
1 Unordered List <ul> Defines unordered list.
2 Ordered List <ol> Defines Ordered list.
3 List Item <li> It defines the list item in a
list.
4 Description list <dl> It defines a description list.
5 Description term <dt> It defines a term or name in a
description list.
6 Description Defination <dd> It describes each term in a
description list.
</body>
</html>
Output
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
Output
</body>
</html>
Output
(b) Write a HTML program, to explain the working of hyperlinks using tag and href,
target Attributes.
Solution
Hyperlink: It is a link which help us to refer to a web page or another document. By
default a unvisited link is underlined and blue in color. A visited link is underlined and
purple in color. An active link is underlined and red in color.
HTML Links and the target attribute
_self: It opens the document in a same window as it is clicked.
_blank: It opens the document in a new window as it is clicked.
_parent: It opens the document in a parent frame.
_top: It opens the document in a full body of the window.
Absolute URLS: In absolute urls full url needs to be defined.
For e.g: < a href=[Link]/cse> CSE </a>
Relative URLs: in Relative urls a portion of url needs to be defined.
For e,g: <a href=”/cse”> CSE </a>
Source Code
<html>
<body>
<h2>Absolute URLs</h2>
<p><a href="[Link] target="_blank">W3C</a></p>
<p><a href="[Link] target="_blank">Google</a></p>
<h2>Relative URLs</h2>
<p><a href="html_images.asp">HTML Images</a></p>
<p><a href="/css/[Link]">CSS Tutorial</a></p>
</body>
</html>
Output
(c) Create a HTML document that has your image and your friend’s image with a specific
height and width. Also when clicked on the images it should navigate to their
respective profiles.
<img>: img tag is used for defining image in HTML.
<src>: It is used for source/ path of image file in HTML.
<alt>: It is used for alternate text of image in HTML.
Source Code
html>
<body>
<h2>Image as a Link</h2>
<a href="[Link]">
<img src="[Link]" alt="HTML tutorial" style="width:42px;height:42px;">
</a>
</body>
</html>
Output
(d) Write a HTML program, in such a way that, rather than placing large images on a
page, the preferred technique is to use thumbnails by setting the height and width
parameters to something like to 100*100 pixels. Each thumbnail image is also a link
to a full sized version of the image. Create an image gallery using this technique.
Source Code
html>
<body>
<h2>Image as a Link</h2>
<a href="[Link]">
<img src="[Link]" alt="HTML tutorial" style="width:100px;height:100px;">
</a>
</body>
</html>
Output
Experiment 2
HTML Tables, Forms and Frames
(a) Write a HTML program, to explain the working of tables.
(b) Write a HTML program, to explain the working of tables by preparing a timetable.
(c) Write a HTML program, to explain the working of forms by designing Registration
form.
(d) Write a HTML program, to explain the working of frames, such that page is to be
divided into 3 parts on either direction.
HTML Table: A table in HTML consist of table cells inside rows and collmns. Table is
defined by <table> tag.
e.g: <table>
</table>
HTML Table tags
[Link] Name of the Tag Description of the Tag
1 <table> Defines a table.
2 <th> Defines a header cell in a table.
3 <tr> Defines a row in a table.
4 <td> Define a cell in a table.
5 <caption> Define a table caption.
6 <colgroup> Specify a group of one or more column in a table for
formatting.
7 <col> Specifies column properties for each column within a
<colgroup> element.
8 <thead> Groups the header content in a table.
9 <tbody> Groups the body content in a table.
10 <tfoot> Groups the footer content in a table.
<h2>Table in HTML</h2>
<table border="solid">
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
</table>
</body>
</html>
Output
(b) Aim: Write a HTML program, to explain the working of tables by preparing a
timetable.
<html>
<head>
<title> II [Link] II Sem CSE C Class Time table </title>
</head>
<body>
<table border="solid">
<tr>
<th colspan="9"> Academic Year: 2024-2025 II [Link] II Sem
CSE C Room No: G11</th>
</tr>
<tr>
<td rowspan="2"> Days</td><td> 9:00 AM - 10:00
AM</td><td> 10:00 AM - 11:00 AM</td><td> 11:00 AM - 12:00 PM</td><td> 12:00 PM -
12:30 PM</td><td> 12:30 PM - 1:30 PM</td><td> 1:30 PM - 2:20 PM</td><td> 2:20 PM -
3:10 PM</td><td> 3:10 PM - 4:00 PM</td>
<tr>
<td>1</td><td>2</td><td>3</td><td rowspan="7"> LUNCH
BREAK</td><td>4</td><td>5</td><td>6</td><td>7</td>
</tr>
</tr>
<tr>
<td> Monday</td><td> SE </td><td> P&S </td><td> DBMS
</td><td> OS </td><td> P&S </td><td> MEFA </td><td> DBMS </td>
</tr>
<tr>
<td> Tuesday</td><td> OS </td><td> DBMS </td><td>
MEFA </td><td> SE </td><td colspan="3"> Database Management System Laboratory
</td>
</tr>
<tr>
<td> Wednesday</td><td> SE </td><td> P&S </td><td>
DBMS </td><td> SS </td><td> OS </td><td> APT </td><td> DBMS </td>
</tr>
<tr>
<td> Thursday</td><td colspan="3"> Full stack Development -
I Laboratory</td><td> P&S </td><td> MEFA </td><td> SE </td><td> OS </td>
</tr>
<tr>
<td> Friday</td><td colspan="3"> Design Thinking &
Innovation </td><td> TECH C </td><td> DBMS </td><td> MEFA </td><td> SE </td>
</tr>
<tr>
<td> Saturday</td><td> P&S </td><td> MEFA </td><td> OS
</td><td> SE </td><td colspan="3"> Operating System Laboratory </td>
</tr>
</table>
</body>
</html>
Output
(c) Aim: Write a HTML program, to explain the working of forms by designing Registration
form.
Form in HTML: Form is used to collect user input. The user input is most often sent to a
server for processing like storing, analysing etc.
HTML Form tags
[Link] Name of the Tag Description of the Tag
1 <input type="text"> Displays a single-line text input field.
2 <input type="radio"> Display a radio button (for selecting one of many
choice).
3 <input type="checkbox"> Displays a checkbox (for selecting zero or more of
many choices).
4 <input type="submit"> Displays a submit button (for submitting the form).
5 <input type="button"> Displays a clickable button.
<h2>Form In HTML</h2>
<form>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" ><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname">
<br><br>
<input type="submit" id="sbutton" name="sbutton">
</form>
</body>
</html>
Output
(d) Write a HTML program, to explain the working of frames, such that page is to be
divided into 3 parts on either direction.
(a) Aim: Write a HTML program, that makes use of <article>,<aside>, <figure>,
<figcaption>, <footer>, <header>, <main>, <nav>, <section>, <div>, <span> tags.
<article> tag: Article tag in HTML represent a self-contained composition in a
document, page, application, site which is intended to be independently reuseable.
Program of article tag
<html>
<head>
<title> Syntax of article tag</title>
</head>
<body>
<article>
<h1> Writing article tag</h1>
<p>
It is an article tag.
</p>
</article>
</body>
</html>
Output
<aside> tag: Aside tag is a semantic element introduced to markup content that is indirectly
related to the main article content of a page.
Program for aside tag
<!DOCTYPE html>
<html>
<head>
<title> Syntax for aside tag</title>
</head>
<body>
<aside>
<h1> Writing aside tag</h1>
<p>
It is an aside tag.
</p>
</aside>
</body>
</html>
Output
<figure> tag: Figure tag in HTML specifies self-contained content like illustrations, diagram,
photos, code listings etc.
Program of figure tag
<html>
<head>
<title> Usage of Figure tag</title>
</head>
<body>
<h1>Figure tag</h1>
<figure>
<img src="pic_trulli.jpg" alt="Trulli" style="width:100%">
</figure>
</body>
</html>
Output
<figcaption> tag: Figcaption in HTML defines a caption for a <figure> element.
Program of <figcaption> tag
<html>
<head>
<title> Usage of Figure and Figcaption</title>
</head>
<body>
<figure>
<img src="pic_trulli.jpg" alt="Trulli" style="width:100%">
<figcaption>Fig.1 - Trulli, Puglia, Italy</figcaption>
</figure>
</body>
</html>
Output
<footer> tag: Footer tag in HTML is a structural element used to identify the footer of a
page, document, article or section.
Program of footer tag
<html>
<head>
<title> Footer section in HTML</title>
</head>
<body>
<footer>
It is footer section of the page
</footer>
</body>
</html>
Output
<header> tag: Header tag in HTML represents a container for introductory content or s set
of navigational links.
Program of header tag
<html>
<body>
<header>
<h1>A heading here</h1>
</header>
</body>
</html>
Output
<main> tag: Main tag in HTML is a structural element that represent the main content of a
web page.
Output
<nav> tag: The nav element represents a section of a page that links to other pages or to
parts within the page.
<nav>
<a href="/html/">HTML</a> |
<a href="/css/">CSS</a> |
<a href="/js/">JavaScript</a> |
<a href="/python/">Python</a>
</nav>
</body>
</html>
Output
<section> tag: Section in HTML is a structural HTML element used to group together related
elements.
Program of <section> tag
<html>
<body>
<section>
<h2>WWF's Symbol</h2>
<p>The Panda has become the symbol of WWF. The well-known panda logo of WWF
originated from a panda named Chi Chi that was transferred from the Beijing Zoo to the
London Zoo in the same year of the establishment of WWF.</p>
</section>
</body>
</html>
Output
<div> tag: The HTML <div> tag is a block level element that groups content on a webpage.
<div>
<h2>This is a heading in a div element</h2>
<p>This is some text in a div element.</p>
</div>
</body>
</html>
Output
<span> tag: The span tag is a inline container used to mark up a mark up a part of a text or a
part of document.
Output
(b) Aim: Write a HTML program, to embed audio and video into HTML web page.
<audio> tag: The <audio> tag is used to emend sound content in a document, such as music
or other audio stream. There are three types of audio format supported in the HTML tag:
MP3, WAV, OGG.
<video> tag: The <video> tag is used to embed video content in a document, such as a
movie clip or other video streams. There are three types of video format supported in the
HTML tag: MP3, WAV, OGG.
Video Attributes in Video tag
[Link] Attribute Value Description
1 autoplay autoplay Specifies that the video will start
playing as soon as it is ready
2 controls controls Specifies that video controls should be
displayed (such as a play/pause button
etc).
3 height pixels Sets the height of the video player
4 loop loop Specifies that the video will start over
again, every time it is finished
5 muted muted Specifies that the audio output of the
video should be muted
6 poster URL Specifies an image to be shown while
the video is downloading, or until the
user hits the play button
7 preload auto Specifies if and how the author thinks
metadata the video should be loaded when the
none page loads
8 src URL Specifies the URL of the video file
9 width pixels Sets the width of the video player
<audio controls>
<source src="[Link]" type="audio/ogg">
</audio>
<video width="200px" height="200px" controls>
<source src="movie.mp4" type="video/mp4">
</video>
</body>
</html>
Output
c) Write a program to apply different types (or levels of styles or style specification
formats) - inline, internal, external styles to HTML elements. (identify selector,
property and value).
CSS (Cascading Style Sheet) describes the HTML elements which are displayed
on screen, paper, or in other media. It saves a lot of time. It controls the layout of
multiple web pages at one time. It sets the font-size, font-family, color, background
color on the page.
There are 3 types of CSS which are below:
o Inline CSS
o Internal/ Embedded CSS
o External CSS
1. Internal CSS
The Internal CSS has <style> tag in the <head> section of the HTML document. This
CSS style is an effective way to style single pages. Using the CSS style for multiple web
pages is time-consuming because we require placing the style on each web page.
We can use the internal CSS by using the following steps:
1. Firstly, open the HTML page and locate the <head>
2. Put the following code after the <head>
3. Add the rules of CSS in the new line.
4. Close the style tag.
2. External CSS
In external CSS, we link the web pages to the external .css file. It is created by text
editor. The CSS is more efficient method for styling a website. By editing the .css file,
we can change the whole site at once.
To use the external CSS, follow the steps, given below:
1. Create a new .css file with text editor, and add Cascading Style Sheet rules
too.
2. Add a reference to the external .cssfile right after <title> tag in
the <head> section of HTML sheet
Pros of External CSS:
o Our files have a cleaner structure and smaller in size.
o We use the same .css file for multiple web pages in external CSS.
Cons of External CSS:
o The pages cannot be delivered correctly before the external CSS is loaded.
o In External CSS, uploading many CSS files can increase the download time of a
website.
Program of external CSS
HTML Page Code
<html>
<head>
<link rel="stylesheet" href="[Link]" />
</head>
<body>
<div class="main">
<h1 class="G">
This is h1 tag
</h1>
<p id="g">
A computer science portal for geeks
</p>
</div>
</body>
</html>
.G {
font-size: 60px;
color: green;
}
#g {
font-size: 25px;
color: skyblue;
};
3. Inline CSS
Inline CSS is used to style a specific HTML element. Add a style attribute to each HTML
tag without using the selectors. Managing a website may difficult if we use only inline
CSS. However, Inline CSS in HTML is useful in some situations. We have not access
the CSS files or to apply styles to element.
Pros of inline CSS:
o We can create CSS rules on the HTML page.
o We cannot create and upload a separate document in inline CSS.
Cons of inline CSS:
o Inline CSS, adding CSS rules to HTML elements is time-consuming and messes up
the HTML structure.
o It styles multiple elements at the same time which can affect the page size and
download time of the page.
<head>
<style>
body {
background-color: #e0e0e0;
font-family: 'Courier New', Courier, monospace;
}
h2 {
color: #09912b;
text-align: left;
}
p{
font-size: 16px;
color: #0a0a0a;
}
</style>
<title>Internal CSS Example</title>
</head>
<body>
<h2>Internal CSS Demo </h2>
<p>
This paragraph is styled using internal CSS.
The styles are defined within the
<style> tag inside the HTML document.
</p>
</body>
</html>
Experiment 4
Aim: Selector forms
Write a program to apply different types of selector forms
Simple selector (element, id, class, group, universal)
Combinator selector (descendant, child, adjacent sibling, general sibling)
Pseudo-class selector
Pseudo-element selector
Attribute selector
Simple Selector
[Link] Types of Simple Selector Description of different types of Simple
Selector
1 Selects HTML elements based on their tag
Element Selector
names.
2 Targets an HTML element with a specific id
Id Selector
attribute.
3 Selects elements with a particular class
Class Selector
attribute.
Output
Output
Ouput
CSS Combinators
There are four different types of CSS Combinators. These are:
Descendant Combinator.
Child Combinator.
Next sibling Combinator
Subsequent Sibling Combinator.
Descendant Combinator: The descendant combinator matches all the elements that are
descendants of a specified element.
Code for Descendant Combinator
<html>
<head>
<style>
div p {
background-color: yellow;
}
</style>
</head>
<body>
<h2>Descendant Selector</h2>
<p>The descendant selector matches all elements that are descendants of a specified
element.</p>
<div>
<p>Paragraph 1 in the div.</p>
<p>Paragraph 2 in the div.</p>
<section><p>Paragraph 3 in the div.</p></section>
</div>
</body>
</html>
Output
Child Combinator: The child combinator selects all elements that are the children of a
specified element.
<h2>Child Selector</h2>
<p>The child selector (>) selects all elements that are the children of a specified
element.</p>
<div>
<p>Paragraph 1 in the div.</p>
<p>Paragraph 2 in the div.</p>
<section>
<!-- not Child but Descendant -->
<p>Paragraph 3 in the div (inside a section element).</p>
</section>
<p>Paragraph 4 in the div.</p>
</div>
</body>
</html>
Output
Next Sibling Combinator: The next sibling combinator is used to select an element that is
directly after another specific element.
Code for next sibling combinator
<html>
<head>
<style>
div + p {
background-color: yellow;
}
</style>
</head>
<body>
<p>The + selector is used to select an element that is directly after another specific
element.</p>
<p>The following example selects the first p element that are placed immediately after div
elements:</p>
<div>
<p>Paragraph 1 in the div.</p>
<p>Paragraph 2 in the div.</p>
</div>
<div>
<p>Paragraph 5 in the div.</p>
<p>Paragraph 6 in the div.</p>
</div>
</body>
</html>
Output
Subsequent- sibling Combinator: The subsequent-sibling combinator selects all elements
that are next siblings of a specified element.
Code for Subsequent – Sibling Combinator
<html>
<head>
<style>
div ~ p {
background-color: yellow;
}
</style>
</head>
<body>
<p>The general sibling selector (~) selects all elements that are next siblings of a specified
element.</p>
<p>Paragraph 1.</p>
<div>
<p>Paragraph 2.</p>
</div>
<p>Paragraph 3.</p>
<code>Some code.</code>
<p>Paragraph 4.</p>
</body>
</html>
Output
/* visited link */
a:visited {
color: green;
}
/* selected link */
a:active {
color: blue;
}
</style>
</head>
<body>
Output
Pseudo element
Code for Pseudo element
<html>
<head>
<style>
p::first-line {
color: #ff0000;
font-variant: small-caps;
}
</style>
</head>
<body>
<p>You can use the ::first-line pseudo-element to add a special effect to the first line of a text.
Some more text. And even more, and more, and more, and more, and more, and more, and
more, and more, and more, and more, and more, and more.</p>
</body>
</html>
Output
Attribute selector
<a href="[Link]
<a href="[Link] target="_blank">[Link]</a>
<a href="[Link] target="_top">[Link]</a>
</body>
</html>
Output
Experiment 5
Aim: CSS with Color, Background, Font, Text and CSS Box Model
(a) Write a program to demonstrate the various ways you can reference a color in CSS.
(b) Write a CSS rule that places a background image halfway down the page, tilting it
horizontally. The image should remain in place when the user scrolls up or down.
(c) Write a program using the following terms related to CSS font and text: i. font-size ii.
font-weight iii. font-style
(d) Write a program, to explain the importance of CSS Box model using [Link] ii.
Border iii. Margin iv. padding
(a) Aim: Write a program to demonstrate the various ways you can reference a color in
CSS.
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Color References</title>
<style>
body {
font-family: Arial, sans-serif;
}
.color-box {
width: 200px;
height: 100px;
margin: 10px;
display: inline-block;
text-align: center;
color: white;
line-height: 100px;
font-weight: bold;
}
.named-color {
background-color: red; /* Named color */
}
.hex-color {
background-color: #FF5733; /* Hexadecimal color */
}
.rgb-color {
background-color: rgb(255, 87, 51); /* RGB color */
}
.rgba-color {
background-color: rgba(255, 87, 51, 0.5); /* RGBA color */
}
.hsl-color {
background-color: hsl(9, 100%, 60%); /* HSL color */
}
.hsla-color {
background-color: hsla(9, 100%, 60%, 0.5); /* HSLA color */
}
.color-function {
background-color: rgb(100%, 50%, 30%); /* Color function (percentage) */
}
</style>
</head>
<body>
</body>
</html>
Output
(b) Aim: Write a CSS rule that places a background image halfway down the page,
tilting it horizontally. The image should remain in place when the user scrolls up or
down.
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fixed Background Image</title>
<style>
/* Apply the background image to the entire HTML document */
html {
height: 100%; /* Ensures the HTML takes full height */
}
body {
background-image: url(''); /* Set your image URL here */
background-position: center 50%; /* Positions the image horizontally centered and
vertically halfway */
background-size: cover; /* Ensures the image covers the whole viewport */
background-attachment: fixed; /* Keeps the image fixed when scrolling */
transform: rotate(45deg); /* Tilts the image horizontally */
height: 100%; /* Ensures body takes full height */
margin: 0; /* Removes default margin */
}
<div class="content">
<h1>Fixed Background with Tilt</h1>
<p>This background stays in place even as you scroll. The image is centered horizontally
and tilted.</p>
</div>
</body>
</html>
(c) Aim: Write a program using the following terms related to CSS font and text:
i. font-size ii. font-weight iii. font-style
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Font and Text Styling</title>
<style>
/* Styling for the heading */
h1 {
font-size: 36px; /* Set the font size to 36px */
font-weight: bold; /* Make the font bold */
font-style: italic; /* Apply italic style to the text */
color: #2c3e50; /* Set the color of the text */
text-align: center; /* Center align the text */
margin-top: 50px; /* Add space above the heading */
}
<p>This is a paragraph of text. The font size is set to 18px, and the font weight is normal.
The text style is also normal, which is the default.</p>
Output
(d) Aim: Write a program, to explain the importance of CSS Box model using
i. Content ii. Border iii. Margin iv. padding
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Box Model</title>
<style>
/* Styling the box element to demonstrate the box model */
.box {
width: 300px; /* Set the width of the content area */
height: 200px; /* Set the height of the content area */
background-color: lightblue; /* Set the background color of the content */
<div class="container">
<!-- Box to demonstrate the CSS Box Model -->
<div class="box">
Box Model Example
</div>
</div>
</body>
</html>
Output
Experiment 6
Aim: Applying JavaScript - internal and external, I/O, Type Conversion
(a) Write a program to embed internal and external JavaScript in a web page.
(b) Write a program to explain the different ways for displaying output.
(c) Write a program to explain the different ways for taking input.
Create a webpage which uses prompt dialogue box to ask a voter for his name and age.
Display the information in table format along with either the voter can vote or not.
Solution
(a) Aim: Write a program to embed internal and external JavaScript in a web page.
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Example</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
}
</style>
</head>
<body>
<h1>Embedding Internal and External JavaScript</h1>
<p id="message"></p>
</body>
</html>
<hr>
<script>
// Method 1: Alert Method
function showAlert() {
alert("This is an alert message!"); // Pops up an alert box with the message
}
</body>
</html>
C)
Aim: Write a program to explain the different ways for taking input.
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Taking Input in JavaScript</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 30px;
}
input, button {
margin-top: 10px;
padding: 10px;
font-size: 16px;
}
</style>
</head>
<body>
<h1>Different Ways to Take Input in JavaScript</h1>
<hr>
<hr>
<script>
// Method 1: Using prompt() to get input from the user
function promptInput() {
var name = prompt("Please enter your name:");
if (name != null) {
[Link]("prompt-output").innerHTML = "Hello, " + name + "!
You entered your name using prompt().";
}
}
Solution
i. Aim: Write a program using document object properties and methods.
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document Object Example</title>
<style>
.text {
font-size: 20px;
color: black;
}
</style>
</head>
<body>
<h1 id="header">Welcome to the Document Object Example</h1>
<p id="text" class="text">This is a sample text. Click the button below to change
its content and style.</p>
<script>
// Changing content using [Link]()
function changeContent() {
// Access the paragraph element
var paragraph = [Link]("text");
(ii) Aim: Write a program using window object properties and methods.
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Window Object Example</title>
</head>
<body>
<h1>Window Object Methods and Properties</h1>
<script>
// 1. Window Alert Example
function showAlert() {
[Link]("This is an alert using the window object!");
}
(iii) Aim: Write a program using array object properties and methods.
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Array Object Methods and Properties</title>
</head>
<body>
<h1>Array Object Methods and Properties Example</h1>
<h3>Array Contents:</h3>
<ul id="arrayList"></ul>
<script>
// Initial array
let myArray = ["apple", "banana", "cherry"];
iv) Aim: Write a program using math object properties and methods.
Source Code
// Math Object Example Program
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>String Object Methods Example</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
.output {
margin-top: 10px;
}
</style>
</head>
<body>
<script>
function performStringOperations() {
// Get the input value from the text box
let inputString = [Link]("inputString").value;
// 1. String length
output += `<p><strong>Length of the string:</strong> ${[Link]}</p>`;
// 2. Convert to uppercase
output += `<p><strong>Uppercase:</strong> ${[Link]()}</p>`;
// 3. Convert to lowercase
output += `<p><strong>Lowercase:</strong> ${[Link]()}</p>`;
// 4. Trim whitespace from both ends
output += `<p><strong>Trimmed string:</strong> "${[Link]()}"</p>`;
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>String Methods in JavaScript</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
}
.output {
margin-top: 20px;
}
</style>
</head>
<body>
<script>
function showStringOperations() {
// Get the input string from the user
const inputString = [Link]('inputString').value;
// Replace a substring
const replacedString = [Link]("World", "JavaScript");
// Find a substring
const indexOfWorld = [Link]("World");
// Trim spaces (if any)
const trimmedString = [Link]();
</body>
</html>
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Regex Methods in JavaScript</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
}
.output {
margin-top: 20px;
}
</style>
</head>
<body>
<script>
function performRegexOperations() {
// Get the input string and regex pattern from the user
const inputString = [Link]('inputString').value;
const regexPattern = [Link]('regexPattern').value;
// .exec() - Executes the regex on the string and returns matched groups (if any)
const execResult = [Link](inputString);
// .split() - Splits the string into an array based on the regex pattern
const splitResult = [Link](regex);
</body>
</html>
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Date Object Methods in JavaScript</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
}
.output {
margin-top: 20px;
}
</style>
</head>
<body>
<h1>JavaScript Date Object Methods and Properties</h1>
<script>
function showCurrentDate() {
const currentDate = new Date();
function addDaysToCurrentDate() {
const daysToAdd = parseInt([Link]('daysToAdd').value);
if (isNaN(daysToAdd)) {
[Link]('output').innerHTML = 'Please enter a valid number of
days.';
return;
}
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User-Defined Object in JavaScript</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
}
.output {
margin-top: 20px;
}
</style>
</head>
<body>
<script>
// Constructor function to create a Person object
function Person(name, age) {
// Properties
[Link] = name;
[Link] = age;
</body>
</html>
Experiment 8
Aim: Java Script Conditional Statements and Loops
a. Write a program which asks the user to enter three integers, obtains the numbers from
the user and outputs HTML text that displays the larger number followed by the words
“LARGER NUMBER” in an information message dialog. If the numbers are equal,
output HTML text as “EQUAL NUMBERS”.
b. Write a program to display week days using switch case.
c. Write a program to print 1 to 10 numbers using for, while and do-while loops.
d. Write a program to print data in object using for-in, for-each and for-of loops
e. Develop a program to determine whether a given number is an ‘ARMSTRONG
NUMBER’ or not. [Eg: 153 is an Armstrong number, since sum of the cube of the digits is
equal to the number i.e.,13 + 53+ 33 = 153]
f. Write a program to display the denomination of the amount deposited in the bank in
terms of 100’s, 50’s, 20’s, 10’s, 5’s, 2’s & 1’s. (Eg: If deposited amount is Rs.163, the
output should be 1 - 100’s, 1-50’s, 1- 10’s, 1-2’s & 1-1’s)
Solution
a. Aim: Write a program which asks the user to enter three integers, obtains the
numbers from the user and outputs HTML text that displays the larger number
followed by the words “LARGER NUMBER” in an information message
dialog. If the numbers are equal, output HTML text as “EQUAL NUMBERS”.
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Compare Numbers</title>
<script>
function compareNumbers() {
// Prompt the user to enter three integers
let num1 = parseInt(prompt("Enter the first number:"));
let num2 = parseInt(prompt("Enter the second number:"));
let num3 = parseInt(prompt("Enter the third number:"));
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weekday Display</title>
<script>
function displayWeekday() {
// Prompt user to enter a number (0-6)
let dayNumber = parseInt(prompt("Enter a number (0-6) to get the
weekday:"));
c. Aim: Write a program to print 1 to 10 numbers using for, while and do-while
loops.
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Print Numbers 1 to 10</title>
<script>
function printNumbers() {
// Using for loop
let resultFor = "For Loop: ";
for (let i = 1; i <= 10; i++) {
resultFor += i + " ";
}
d. Aim: Write a program to print data in object using for-in, for-each and for-of
loops.
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Looping through Object</title>
</head>
<body>
<div id="forInLoop"></div>
<div id="forEachLoop"></div>
<div id="forOfLoop"></div>
<script>
// Define an object with some data
const person = {
name: "John",
age: 30,
occupation: "Developer"
};
// 2. Using forEach loop (we need to use [Link] to iterate over the
object in array form)
let forEachResult = "";
[Link](person).forEach(([key, value]) => {
forEachResult += `${key}: ${value}<br>`;
});
[Link]("forEachLoop").innerHTML = `<h2>Using
forEach loop:</h2>${forEachResult}`;
// 3. Using for-of loop (we need to convert the object into an array using
[Link])
let forOfResult = "";
for (const [key, value] of [Link](person)) {
forOfResult += `${key}: ${value}<br>`;
}
[Link]("forOfLoop").innerHTML = `<h2>Using for-of
loop:</h2>${forOfResult}`;
</script>
</body>
</html>
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Armstrong Number Check</title>
</head>
<body>
<script>
// Function to check if a number is Armstrong
function checkArmstrong() {
const number = parseInt([Link]("number").value);
if (isNaN(number)) {
[Link]("result").innerHTML = "Please enter a valid
number!";
return;
}
// Loop through each digit, raise it to the power of the number of digits,
and sum it
for (let i = 0; i < numDigits; i++) {
const digit = parseInt([Link](i));
sum += [Link](digit, numDigits);
}
</body>
</html>
<div id="result"></div>
<script>
function calculateDenomination() {
const amount = parseInt([Link]("amount").value);
if (denominationCount > 0) {
result += `${denominationCount} - ${denominations[i]}'s<br>`;
}
</body>
</html>
Experiment 9
Aim: Java Script Functions and Events
a. Design a appropriate function should be called to display
i. Factorial of that number ii. Fibonacci series up to that number iii. Prime numbers up to
that number iv. Is it palindrome or not
b. Design a HTML having a text box and four buttons named Factorial, Fibonacci, Prime, and
Palindrome. When a button is pressed an appropriate function should be called to display
i. Factorial of that number ii. Fibonacci series up to that number iii. Prime numbers up to that
number iv. Is it palindrome or not
c. Write a program to validate the following fields in a registration page
i. Name (start with alphabet and followed by alphanumeric and the length should not be less
than 6 characters) ii. Mobile (only numbers and length 10 digits) iii. E-mail (should contain
format like xxxxxxx@[Link])
Solution
a. Aim: Design a appropriate function should be called to display
i. Factorial of that number ii. Fibonacci series up to that number
iii. Prime numbers up to that number iv. Is it palindrome or not
Solution
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Number Operations</title>
</head>
<body>
<h1>Number Operations</h1>
<h2>Results:</h2>
<div id="factorialResult"></div>
<div id="fibonacciResult"></div>
<div id="primeResult"></div>
<div id="palindromeResult"></div>
<script>
// Function to calculate factorial of a number
function factorial(n) {
if (n < 0) return "Factorial is not defined for negative numbers";
let fact = 1;
for (let i = 1; i <= n; i++) {
fact *= i;
}
return fact;
}
// Factorial
const factResult = factorial(number);
[Link]("factorialResult").innerHTML = `<strong>Factorial:</strong>
${factResult}`;
// Fibonacci series
const fibonacciResult = fibonacci(number);
[Link]("fibonacciResult").innerHTML = `<strong>Fibonacci series
up to ${number}:</strong> ${fibonacciResult}`;
// Prime numbers
const primeResult = primesUpTo(number);
[Link]("primeResult").innerHTML = `<strong>Prime numbers up to
${number}:</strong> ${primeResult}`;
// Palindrome check
const palindromeResult = isPalindrome(number);
[Link]("palindromeResult").innerHTML = `<strong>Palindrome
check:</strong> ${palindromeResult}`;
}
</script>
</body>
</html>
b. Aim: Design a HTML having a text box and four buttons named Factorial, Fibonacci,
Prime, and Palindrome. When a button is pressed an appropriate function should be called to
display
i. Factorial of that number ii. Fibonacci series up to that number iii. Prime numbers up to that
number iv. Is it palindrome or not
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Number Operations</title>
</head>
<body>
<h1>Number Operations</h1>
<button onclick="calculateFactorial()">Factorial</button>
<button onclick="calculateFibonacci()">Fibonacci</button>
<button onclick="calculatePrimes()">Prime Numbers</button>
<button onclick="checkPalindrome()">Palindrome Check</button>
<h2>Results:</h2>
<div id="factorialResult"></div>
<div id="fibonacciResult"></div>
<div id="primeResult"></div>
<div id="palindromeResult"></div>
<script>
// Function to calculate factorial of a number
function calculateFactorial() {
const number = parseInt([Link]("number").value);
let result = 1;
if (isNaN(number) || number < 0) {
[Link]("factorialResult").innerHTML = "Please enter a valid
positive number.";
return;
}
for (let i = 1; i <= number; i++) {
result *= i;
}
[Link]("factorialResult").innerHTML = `<strong>Factorial of $
{number}:</strong> ${result}`;
}
</body>
</html>
Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Form Validation</title>
</head>
<body>
<h1>Registration Form</h1>
<form id="registrationForm" onsubmit="return validateForm()">
<!-- Name Input Field -->
<label for="name">Name (Start with alphabet, followed by alphanumeric, min 6
chars):</label>
<input type="text" id="name" name="name" required><br><br>
<div id="errorMessages"></div>
<script>
// Function to validate the form fields
function validateForm() {
// Get values from the form fields
const name = [Link]("name").value;
const mobile = [Link]("mobile").value;
const email = [Link]("email").value;
// If there are error messages, display them and prevent form submission
if ([Link] > 0) {
[Link]("errorMessages").innerHTML = "<ul>" +
[Link](msg => `<li>${msg}</li>`).join('') + "</ul>";
return false; // Prevent form submission
}
</body>
</html>