FSD Lab
FSD Lab
<!DOCTYPE html>
<html>
<head>
<title>Lists in HTML</title>
</head>
<body>
<h2>Ordered List</h2>
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
<h2>Unordered List</h2>
<ul>
<li>Item A</li>
<li>Item B</li>
<li>Item C</li>
</ul>
<h2>Nested List</h2>
<ul>
<li>Fruits
<ul>
<li>Apple</li>
<li>Banana</li>
</ul>
</li>
<li>Vegetables
<ul>
<li>Carrot</li>
<li>Broccoli</li>
</ul>
</li>
</ul>
<h2>Definition List</h2>
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
</dl>
</body>
</html>
Output:-
Ordered List
1. Item 1
2. Item 2
3. Item 3
Unordered List
Item A
Item B
Item C
Nested List
Fruits
o Apple
o Banana
Vegetables
o Carrot
o Broccoli
Definition List
<!DOCTYPE html>
<html>
<head>
<title>Hyperlinks in HTML</title>
</head>
<body>
<h2>Links with Target Attribute</h2>
<a href="https://www.google.com" target="_blank">Open Google in
New Tab</a>
<br>
<a href="https://www.wikipedia.org" target="_self">Open Wikipedia
in Same Tab</a>
</body>
</html>
Output:-
Aim: To create an HTML document that displays images of the user and
<!DOCTYPE html>
<html>
<head>
<title>Image Links</title>
</head>
<body>
<h2>Profile Images with Links</h2>
<a href="https://www.example.com/myprofile" target="_blank">
<img src="myimage.jpg" alt="My Image" width="200"
height="200">
</a>
<a href="https://www.example.com/friendprofile" target="_blank">
<img src="friendimage.jpg" alt="Friend's Image" width="200"
height="200">
</a>
</body>
</html>
Output:-
https://www.example.com/myprofile
Aim :To create an image gallery using thumbnail images that link to full-sized
versions.
<!DOCTYPE html>
<html>
<head>
<title>Image Gallery</title>
</head>
<body>
<h2>Thumbnail Image Gallery</h2>
<a href="fullsize1.jpg" target="_blank">
<img src="thumb1.jpg" alt="Image 1" width="100" height="100">
</a>
<a href="fullsize2.jpg" target="_blank">
<img src="thumb2.jpg" alt="Image 2" width="100" height="100">
</a>
<a href="fullsize3.jpg" target="_blank">
<img src="thumb3.jpg" alt="Image 3" width="100" height="100">
</a>
</body>
</html>
Output:-
Experiment 2: HTML Tables, Forms and Frames
Aim: To understand how to work with tables and use tags such as <table>, <tr>,
<th>, <td>, and attributes like border, rowspan, and colspan.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>HTML Tables Example</title>
</head>
<body>
<h2>HTML Table Example</h2>
<table border="1">
<tr>
<th>Name</th>
<th>Age</th>
<th>City</th>
</tr>
<tr>
<td>John</td>
<td>25</td>
<td>New York</td>
</tr>
<tr>
<td>Mary</td>
<td>22</td>
<td>Los Angeles</td>
</tr>
<tr>
<td colspan="2">Total</td>
<td>2</td>
</tr>
</table>
</body>
</html>
Output:-
Aim: To create a timetable using tables, utilizing tags like <caption>, and attributes
such as cellspacing, cellpadding, border, rowspan, colspan.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Timetable Example</title>
</head>
<body>
<h2>Weekly Timetable</h2>
<table border="1" cellspacing="0" cellpadding="10">
<caption>Class Timetable</caption>
<tr>
<th>Day</th>
<th>8:00 AM - 9:00 AM</th>
<th>9:00 AM - 10:00 AM</th>
<th>10:00 AM - 11:00 AM</th>
</tr>
<tr>
<td>Monday</td>
<td>Math</td>
<td>English</td>
<td rowspan="2">Break</td>
</tr>
<tr>
<td>Tuesday</td>
<td>Science</td>
<td>History</td>
</tr>
<tr>
<td>Wednesday</td>
<td>Art</td>
<td>Physical Education</td>
<td>Music</td>
</tr>
</table>
</body>
</html>
Output:-
Weekly Timetable
Class Timetable
Physical
Wednesday Art Music
Education
Aim: To design a registration form with various input fields (text, password, number,
date, checkboxes, radio buttons, list boxes) using tables for layout.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Registration Form</title>
</head>
<body>
<h2>Registration Form</h2>
<form action="#" method="post">
<table border="0">
<tr>
<td>Name:</td>
<td><input type="text" name="name" required></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password"
required></td>
</tr>
<tr>
<td>Age:</td>
<td><input type="number" name="age" required></td>
</tr>
<tr>
<td>Date of Birth:</td>
<td><input type="date" name="dob" required></td>
</tr>
<tr>
<td>Gender:</td>
<td>
<input type="radio" name="gender" value="Male">
Male
<input type="radio" name="gender" value="Female">
Female
</td>
</tr>
<tr>
<td>Hobbies:</td>
<td>
<input type="checkbox" name="hobbies"
value="Reading"> Reading
<input type="checkbox" name="hobbies"
value="Traveling"> Traveling
</td>
</tr>
<tr>
<td>Country:</td>
<td>
<select name="country">
<option value="USA">USA</option>
<option value="India">India</option>
<option value="UK">UK</option>
</select>
</td>
</tr>
<tr>
<td>Comments:</td>
<td><textarea name="comments" rows="4"
cols="50"></textarea></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
</body>
</html>
Output:-
Aim: To divide the page into 3 frames with different content such as an image,
paragraph, and hyperlink, and to use the "no frame" attribute to ensure fixed frames.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Frames Example</title>
</head>
<body>
<h2>HTML Frames Example</h2>
<frameset rows="30%, 40%, 30%">
<frame src="image.jpg" />
<frame src="paragraph.html" />
<frame src="link.html" />
</frameset>
<noframes>
<p>Your browser does not support frames. Please update your
browser.</p>
</noframes>
</body>
</html>
Output (If Files Exist)
Aim: To demonstrate the use of various HTML5 semantic tags for structuring the web
page content.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>HTML5 Semantic Tags</title>
</head>
<body>
<header>
<h1>Website Header</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section>
<h2>Main Content Section</h2>
<article>
<h3>Article Title</h3>
<p>This is the main content of the article.</p>
</article>
<aside>
<h4>Related Information</h4>
<p>Here is some additional information related to the
article.</p>
</aside>
</section>
</main>
<footer>
<p>Website Footer Information © 2025</p>
</footer>
<div>
<h2>Another Section Inside a div</h2>
<p>This is wrapped in a div tag for layout purposes.</p>
<span>This is a span tag, typically used for styling specific
text.</span>
</div>
<figure>
<img src="image.jpg" alt="Example Image">
<figcaption>Example Image Caption</figcaption>
</figure>
</body>
</html>
Output:-
Aim: To demonstrate how to embed audio and video elements using HTML5.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Audio and Video Embedding</title>
</head>
<body>
<h2>Audio and Video Example</h2>
Output:-
Aim: To demonstrate how to apply different types of CSS (inline, internal, and
external) to HTML elements.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>CSS Types Example</title>
<!-- External CSS Link (This would point to an external CSS file)
-->
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>This is an H1 Header</h1>
<p class="highlight">This is a paragraph with internal CSS
applied for the background color and font weight.</p>
<div>
<h2>This is a Heading Inside a Div</h2>
<p>This paragraph is styled using external CSS (if the file
`styles.css` exists).</p>
</div>
</body>
</html>
Output:-
Experiment 4: Selector forms
Aim: To demonstrate how to use various CSS selectors, including simple selectors,
combinator selectors, pseudo-classes, pseudo-elements, and attribute selectors.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>CSS Selectors Example</title>
<style>
/* Simple Selectors */
/* Element Selector */
h1 {
color: blue;
}
/* ID Selector */
#unique {
font-size: 24px;
font-weight: bold;
}
/* Class Selector */
.highlight {
background-color: yellow;
}
/* Group Selector */
h2, h3 {
color: green;
}
/* Universal Selector */
* {
font-family: Arial, sans-serif;
}
/* Combinator Selectors */
/* Descendant Selector */
article p {
color: purple;
}
/* Child Selector */
section > p {
font-style: italic;
}
/* Pseudo-class Selector */
/* :hover */
a:hover {
color: red;
}
/* :nth-child */
ul li:nth-child(2) {
font-weight: bold;
}
/* Pseudo-element Selector */
/* ::before */
p::before {
content: "Note: ";
font-weight: bold;
color: red;
}
/* ::after */
p::after {
content: " [End of paragraph]";
font-style: italic;
}
/* Attribute Selector */
/* Selecting all anchor tags with a specific href attribute
*/
a[href^="https"] {
color: green;
}
</style>
</head>
<body>
<h1 id="unique">Simple CSS Selectors Example</h1>
<p class="highlight">This is a paragraph with a class selector
applied.</p>
<section>
<p>This paragraph is selected using the child selector.</p>
</section>
<article>
<p>This paragraph is selected using the descendant
selector.</p>
</article>
<h2>Combinator Selectors</h2>
<p>This is a paragraph following an h1 tag and selected by the
adjacent sibling selector.</p>
<h3>General Sibling Selector Example</h3>
<p>This paragraph is a sibling of the h2 element and selected by
the general sibling selector.</p>
Output:-
Experiment5. CSS with Color, Background, Font, Text and CSS Box
Model
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>CSS Color Referencing</title>
<style>
/* Named Color */
.named-color {
background-color: red;
}
/* Hexadecimal */
.hex-color {
background-color: #ff5733;
}
/* RGB */
.rgb-color {
background-color: rgb(60, 179, 113);
}
/* RGBA */
.rgba-color {
background-color: rgba(255, 0, 0, 0.5);
}
/* HSL */
.hsl-color {
background-color: hsl(240, 100%, 50%);
}
/* HSLA */
.hsla-color {
background-color: hsla(120, 100%, 50%, 0.7);
}
div {
width: 200px;
height: 50px;
margin: 10px;
color: white;
text-align: center;
line-height: 50px;
}
</style></head><body>
<div class="named-color">Named Color</div>
<div class="hex-color">Hex Color</div>
<div class="rgb-color">RGB Color</div>
<div class="rgba-color">RGBA Color</div>
<div class="hsl-color">HSL Color</div>
<div class="hsla-color">HSLA Color</div></body></html>
Output:-
b. Background Image Fixed and Positioned
Halfway
Aim: To position a background image halfway down the page while keeping it fixed
when scrolling.
.font-weight {
font-weight: bold;
}
.font-style {
font-style: italic;
}
.text-decoration {
text-decoration: underline;
}
.text-transform {
text-transform: uppercase;
}
.text-align {
text-align: center;
}
</style></head><body>
<p class="font-size">This text has a font size of 24px.</p>
<p class="font-weight">This text is bold.</p>
<p class="font-style">This text is italic.</p>
<p class="text-decoration">This text is underlined.</p>
<p class="text-transform">This text is uppercase.</p>
<p class="text-align">This text is centered.</p></body></html>
Output:-
Output:-
b. Different Ways to Display Output
Aim: To demonstrate various methods to display output in JavaScript.
<script>
// 1. Using alert()
alert("This is an alert box!");
// 2. Using console.log()
console.log("This is displayed in the console.");
// 3. Using document.write()
document.write("<p>This is displayed using
document.write().</p>");
// 4. Using innerHTML
document.getElementById("output").innerHTML = "This is
displayed using innerHTML.";
</script></body></html>
Output:-
c. Different Ways to Take Input
Aim: To demonstrate various methods for getting input in JavaScript.
<p id="displayInput"></p>
<script>
function getInput() {
// 1. Using prompt()
var userPrompt = prompt("Enter something using prompt:");
alert("You entered (prompt): " + userPrompt);
Output:-
d. Voter Eligibility Check
Aim: To create a webpage that asks for a voter's name and age using prompt(), then
displays their eligibility in a table.
<div id="voterInfo"></div>
<script>
function checkVoter() {
var name = prompt("Enter your name:");
var age = prompt("Enter your age:");
Output:-
<script>
document.getElementById("info").innerHTML = "Current URL: " +
document.URL;
function changeTitle() {
document.title = "New Title Set!";
document.write("<h2>Page Title Changed</h2>");
}
</script></body></html>
Output:-
<script>
function showAlert() {
alert("This is an alert box!");
}
function showPrompt() {
var name = prompt("Enter your name:");
alert("Hello, " + name);
}
function openWindow() {
window.open("https://www.google.com", "_blank",
"width=600,height=400");
}
</script></body></html>
Output:-
Output:-
e. String Object Properties and Methods
Aim: To demonstrate string methods like length, toUpperCase(), substring().
Output:-
Output:-
Match Found: true
g. Date Object Properties and Methods
Aim: To demonstrate Date object methods.
Output:-
Today's Date: Thu Feb 20 2025
Current Time: 3:30:59 PM
h. User-Defined Object
Aim: To create a user-defined object with properties, methods, and constructor.
Output:-
document.write(`<h2>Day: ${dayName}</h2>`);
</script></body></html>
Output Scenarios:
Output:-
Using For Loop:
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
Output:-
document.write("<h2>Denomination Breakdown:</h2>");
for (let key in result) {
document.write(`${result[key]} x Rs.${key}<br>`);
}
</script></body></html>
Output:-
Input → 786
Breakdown:
7 x Rs.100
1 x Rs.50
1 x Rs.20
1 x Rs.10
1 x Rs.5
1 x Rs.1
// Example Usage
let num = parseInt(prompt("Enter a number:"));
document.write(`<h3>Factorial of ${num}:
${factorial(num)}</h3>`);
document.write(`<h3>Fibonacci Series: ${fibonacci(num).join(',
')}</h3>`);
document.write(`<h3>Prime Numbers up to ${num}:
${primeNumbers(num).join(', ')}</h3>`);
document.write(`<h3>${num} is ${isPalindrome(num) ? '' :
'not'} a Palindrome</h3>`);
</script></body></html>
<h3>Result:</h3>
<p id="result"></p>
<script>
function getNumber() {
return
parseInt(document.getElementById("numInput").value);
}
function displayFactorial() {
let num = getNumber();
document.getElementById("result").innerHTML = `Factorial:
${factorial(num)}`;
}
function displayFibonacci() {
let num = getNumber();
document.getElementById("result").innerHTML = `Fibonacci
Series: ${fibonacci(num).join(', ')}`;
}
function displayPrimes() {
let num = getNumber();
document.getElementById("result").innerHTML = `Prime
Numbers: ${primeNumbers(num).join(', ')}`;
}
function displayPalindrome() {
let num = getNumber();
let isPal = isPalindrome(num) ? "Yes" : "No";
document.getElementById("result").innerHTML = `${num} is
a Palindrome: ${isPal}`;
}
</script></body></html>
Output:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Registration Form</title>
<script>
function validateForm() {
let name = document.getElementById("name").value;
let email = document.getElementById("email").value;
let password = document.getElementById("password").value;
let confirmPassword = document.getElementById("confirmPassword").value;
let age = document.getElementById("age").value;
if (name.length < 3) {
alert("Name must be at least 3 characters.");
return false;
}
if (!email.includes("@")) {
alert("Enter a valid email.");
return false;
}
if (password.length < 6) {
alert("Password must be at least 6 characters.");
return false;
}
if (password !== confirmPassword) {
alert("Passwords do not match.");
return false;
}
if (age < 18) {
alert("You must be 18 or older.");
return false;
}
alert("Registration Successful!");
return true;
}
</script>
</head>
<body>
<h2>Registration Form</h2>
<form onsubmit="return validateForm()">
<label>Name:</label>
<input type="text" id="name" required><br><br>
<label>Email:</label>
<input type="email" id="email" required><br><br>
<label>Password:</label>
<input type="password" id="password" required><br><br>
<label>Confirm Password:</label>
<input type="password" id="confirmPassword" required><br><br>
<label>Age:</label>
<input type="number" id="age" required><br><br>
<button type="submit">Register</button>
</form>
</body>
</html>
Output:-
Explanation
Experiment 1: Lists, Links, and Images
1A:
Explanation:
1B:
Explanation:
1C:
Explanation:
1D:Explanation:
This program uses small thumbnail images (100x100 pixels) as clickable links to their full-size
versions.
Each <a> tag links to a larger version of the image.
The <img> tag inside <a> creates a clickable thumbnail image.
The target="_blank" attribute ensures the full-sized image opens in a new tab.
Explanation2d:
Explanation2c:
Explanation2d:
Explanation3a:
<header>: Defines the top section of the page, typically for navigation and introductory
content.
<nav>: Defines a navigation menu.
<main>: Contains the primary content of the document.
<section>: Represents a section of related content.
<article>: Represents a self-contained article.
<aside>: Represents content related to the surrounding content, such as a sidebar.
<footer>: Defines the footer of the document.
<div>: A generic container element used for grouping other elements.
<span>: A generic inline container for styling text.
Explanation 3b:
<audio>: Embeds an audio file, with the controls attribute providing play, pause, and
volume control.
<source>: Specifies the file source for audio or video content and its type.
<video>: Embeds a video file, with the controls attribute allowing playback controls.
width="600": Sets the width of the video player.
Explanation 3c:
1. Inline CSS:
o The style attribute is applied directly to an HTML element, specifying CSS rules
like color: red; and font-size: 18px;.
2. Internal CSS:
o CSS is written inside the <style> tag within the <head> section.
o Example: body { font-family: Arial, sans-serif; background-
color: #f4f4f4; }.
3. External CSS:
o The external CSS file is linked using the <link> tag with the href attribute
pointing to the external stylesheet (styles.css in this case).
Explanation of Selectors:
i. Simple Selectors
Element Selector:
1. Selector: h1
2. Description: Targets all <h1> elements and changes their text color to blue.
3. Example: h1 { color: blue; }
ID Selector:
1. Selector: #unique
2. Description: Targets an element with the id="unique", changing its font size and
making it bold.
3. Example: #unique { font-size: 24px; font-weight: bold; }
Class Selector:
1. Selector: .highlight
2. Description: Targets all elements with the class highlight and applies a yellow
background.
3. Example: .highlight { background-color: yellow; }
Group Selector:
1. Selector: h2, h3
2. Description: Targets both <h2> and <h3> elements, making their text color green.
3. Example: h2, h3 { color: green; }
Universal Selector:
1. Selector: *
2. Description: Applies the Arial font family to all elements on the page.
3. Example: * { font-family: Arial, sans-serif; }
Descendant Selector:
1. Selector: article p
2. Description: Selects <p> elements inside <article> tags and sets the text color
to purple.
3. Example: article p { color: purple; }
Child Selector:
1. Selector: h1 + p
2. Description: Selects the first <p> immediately following an <h1> and changes the
text color to red.
3. Example: h1 + p { color: red; }
1. Selector: h2 ~ p
2. Description: Selects all <p> elements that are siblings of <h2> and applies orange
color.
3. Example: h2 ~ p { color: orange; }
:hover:
1. Selector: a:hover
2. Description: Changes the link color to red when the mouse hovers over it.
3. Example: a:hover { color: red;
:nth-child:
1. Selector: ul li:nth-child(2)
2. Description: Targets the second <li> in an unordered list and makes it bold.
3. Example: ul li:nth-child(2) { font-weight: bold; }
::before:
1. Selector: p::before
2. Description: Adds content before the text of each <p> element, labeled as "Note:".
3. Example: p::before { content: "Note: "; font-weight: bold;
color: red; }
::after:
1. Selector: p::after
2. Description: Adds content after each <p> element, labeled as "[End of paragraph]".
3. Example: p::after { content: " [End of paragraph]"; font-
style: italic; }
v. Attribute Selector
1. [href^="https"]:
1. Selector: a[href^="https"]
2. Description: Selects all anchor tags (<a>) where the href attribute starts with
"https", coloring them green.
3. Example: a[href^="https"] { color: green;
Experiment5. CSS with Color, Background, Font, Text and CSS Box
Model
Explanation 5a:
Explanation 5b:
Explanation 5c:
Explanation 5d:
1. Content: The actual text inside the box ("CSS Box Model Example").
2. Padding (padding: 20px;): Creates space between content and border.
3. Border (border: 5px solid black;): A black border around the box.
4. Margin (margin: 30px;): Adds space outside the border, separating it from other
elements.
Experiment6: Applying JavaScript - internal and external, I/O,
Type Conversion
Explanation 6a:
Explanation 6b:
Explanation 6c:
Explanation 6d:
h. User-Defined Object
Takes input and extracts digits using the modulus operator (%).
Cubes each digit and sums them.
If sum equals the original number, it's an Armstrong number.