Web Technologies Practical
Web Technologies Practical
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>index of book</title>
<style>
table,
th,
td {
border: 2px solid black;
border-collapse: collapse;
}
</style>
</head>
<body>
<center>
<h1>INDEX</h1>
<table>
<tr>
<th>Serial No.</th>
<th>Chapter</th>
<th>Page No.</th>
</tr>
<tr>
<td>1.</td>
<td>Introduction to Web Designing</td>
<td>1-12</td>
</tr>
<tr>
<td>2.</td>
<td>HTML Basics</td>
<td>13-20</td>
2
</tr>
<tr>
<td>3.</td>
<td>Basic Formatting tags</td>
<td>21-28</td>
</tr>
<tr>
<td>4.</td>
<td>Tables in HTML</td>
<td>29-35</td>
</tr>
<tr>
<td>5.</td>
<td>Lists in HTML</td>
<td>36-43</td>
</tr>
<tr>
<td>6.</td>
<td>Media in HTML</td>
<td>44-55</td>
</tr>
<tr>
<td>7.</td>
<td>Introduction to CSS</td>
<td>56-61</td>
</tr>
<tr>
<td>8.</td>
<td>Animation in CSS</td>
<td>62-78</td>
</tr>
<tr>
<td>9.</td>
<td>CSS Box Properties</td>
<td>79-85</td>
</tr>
3
<tr>
<td>10.</td>
<td>Introduction to Javascript</td>
<td>86-100</td>
</tr>
</table>
</center>
</body>
</html>
Output
4
</body>
</html>
Output
5
3.Display Letter Head of your college on a web page & it must be scrolling
Right to Left.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Letterhead</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
.letterhead {
border: 2px solid #730c0c;
padding: 20px;
width: 80%;
margin: auto;
6
}
.header {
display: flex;
align-items: center;
justify-content: space-between;
}
.header img {
width: 100px;
height: auto;
}
.title {
text-align: center;
}
.title h1 {
color: #58180b;
margin: 0;
}
.footer {
text-align: center;
margin-top: 20px;
font-size: 12px;
color: gray;
}
</style>
</head>
<body>
<div class="letterhead">
<div class="header">
<img src="ptu.jpeg" alt="IKGPTU Logo">
<div class="title">
<h1>I.K. Gujral Punjab Technical University</h1>
7
4. Create a link to move within a single page rather than to load another
page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Single Page Navigation</title>
</head>
<body>
<h1>Welcome to My Single Page</h1>
Output
9
10
Output
table {
width: 80%;
border-collapse: collapse;
margin: 20px auto;
font-family: Arial, sans-serif;
}
th, td {
border: 1px solid #ccc;
padding: 10px;
text-align: center;
}
th {
background-color: #004080;
color: white;
}
tr:nth-child(even) {
background-color: #f9f9f9;
}
.highlight {
background-color: #ffeb3b; /* Highlight important periods in yellow */
font-weight: bold;
}
</style>
</head>
<body>
<h1 style="text-align: center;">Department Time Table</h1>
<table>
<thead>
<tr>
<th>Day</th>
<th>9:00 AM - 10:00 AM</th>
13
<td>Lunch Break</td>
<td class="highlight">Research Workshop</td>
<td>Team Collaboration</td>
</tr>
<tr>
<td>Thursday</td>
<td>Software Engineering</td>
<td class="highlight">Cloud Computing</td>
<td>Mathematics</td>
<td>Lunch Break</td>
<td>Programming Lab</td>
<td class="highlight">Ethical Hacking</td>
</tr>
<tr>
<td>Friday</td>
<td class="highlight">Web Development</td>
<td>Programming</td>
<td>Operating Systems</td>
<td>Lunch Break</td>
<td>Project Presentations</td>
<td class="highlight">Networking Lab</td>
</tr>
</tbody>
</table>
</body>
</html>
15
Output
<tr>
<td class="menu" style="width: 30%;">Menu<br>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</td>
<td class="content" style="width: 70%;">This is the main
content area.<br>
Here you can add text, images, or anything you want to
showcase.
</td>
</tr>
<tr>
<td colspan="2" class="footer">© 2025 Your Website | All
Rights Reserved</td>
</tr>
</table>
</body>
</html>
18
Output
<h2>Audio</h2>
<p>Here is an audio clip:</p>
<audio controls>
<source src="example-audio.mp3" type="audio/mpeg">
<source src="example-audio.ogg" type="audio/ogg">
</audio>
19
<h2>Video</h2>
<p>Here is a video:</p>
<video controls width="440" height="200">
<source src="example-video.mp4" type="video/mp4">
<source src="example-video.ogg" type="video/ogg">
</video>
</body>
</html>
Output
20
</style>
</head>
<body>
<div class="left-pane">
<img src="ptu.jpeg" alt="College Logo">
</div>
<div class="right-pane">
<img src="ptu.jpeg" alt="University Logo">
</div>
</body>
</html>
Output
<th>Full Name</th>
<td>John Doe</td>
</tr>
<tr>
<th>Date of Birth</th>
<td>01 January 1990</td>
</tr>
<tr>
<th>Contact Number</th>
<td>+91-123-456-7890</td>
</tr>
<tr>
<th>Email</th>
<td>[email protected]</td>
</tr>
<tr>
<th>Address</th>
<td>123 Main Street, City, State, Postal Code</td>
</tr>
<tr>
<th>Gender</th>
<td>Male</td>
</tr>
<tr>
<th>Education</th>
<td>Bachelor of Technology in Computer Science</td>
</tr>
<tr>
<th>Experience</th>
<td>5 years as Software Engineer</td>
</tr>
24
<tr>
<th>Skills</th>
<td>Programming (Java, Python), Web Development, Problem
Solving</td>
</tr>
<tr>
<th>Languages Known</th>
<td>English, Hindi</td>
</tr>
</table>
</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>Hospital Front Page</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f8f9fa;
}
.container {
text-align: center;
padding: 20px;
}
.header {
background-color: #004080;
color: white;
padding: 20px 10px;
}
.header h1 {
margin: 0;
}
.navbar {
26
background-color: #ff6666;
overflow: hidden;
padding: 10px 0;
}
.navbar a {
float: left;
color: white;
padding: 10px 20px;
text-decoration: none;
}
.navbar a:hover {
background-color: #d9534f;
}
.main-content {
display: flex;
justify-content: space-around;
margin-top: 20px;
}
.main-content div {
padding: 20px;
background-color: #e9f5ff;
border: 1px solid #ccc;
width: 30%;
border-radius: 10px;
}
27
.footer {
background-color: #004080;
color: white;
padding: 10px;
margin-top: 20px;
}
</style>
</head>
<body>
<div class="header">
<h1>Welcome to Hospital</h1>
<p>Excellence in healthcare since [Year]</p>
</div>
<div class="navbar">
<a href="#about">About Us</a>
<a href="#services">Services</a>
<a href="#contact">Contact</a>
</div>
<div class="container">
<div class="main-content">
<div>
<h2>Our Mission</h2>
28
<div class="footer">
<p>Contact us: 4567832996 | [email protected]</p>
<p>© 2025 Hospital. All rights reserved.</p>
</div>
</body>
</html>
29
Output
12. Design a web page and display horizontally two different web
pages at a time.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Display Two Web Pages Horizontally</title>
<style>
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}
.container {
display: flex;
height: 100vh;
}
30
.iframe-container {
flex: 1;
border: 2px solid #ccc;
}
.iframe-container iframe {
width: 100%;
height: 100%;
border: none;
}
</style>
</head>
<body>
<div class="container">
<div class="iframe-container">
<iframe src="https://www.example.com" title="Web Page
1"></iframe>
</div>
<div class="iframe-container">
<iframe src="https://www.wikipedia.org" title="Web Page
2"></iframe>
</div>
</div>
</body>
</html>
31
Output
background-color: #f8f9fa;
}
.login-form {
padding: 20px;
border: 1px solid #ccc;
background-color: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.login-form h1 {
margin-bottom: 20px;
}
.login-form input[type="text"], .login-form
input[type="password"] {
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 5px;
}
.login-form input[type="submit"] {
background-color: #004080;
color: white;
border: none;
padding: 10px;
width: 100%;
cursor: pointer;
border-radius: 5px;
}
33
.login-form input[type="submit"]:hover {
background-color: #003060;
}
</style>
</head>
<body>
<form class="login-form" action="profile.html" method="POST">
<h1>Login</h1>
<label for="username">Username:</label>
<input type="text" id="username" name="username"
placeholder="Enter your username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password"
placeholder="Enter your password" required>
<input type="submit" value="Login">
</form>
</body>
</html>
34
Output
padding: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #f8f9fa;
}
.registration-form {
padding: 20px;
border: 1px solid #ccc;
background-color: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.registration-form h1 {
margin-bottom: 20px;
}
.registration-form input {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
}
.registration-form input[type="submit"] {
background-color: #004080;
color: white;
border: none;
cursor: pointer;
36
}
.registration-form input[type="submit"]:hover {
background-color: #003060;
}
</style>
</head>
<body>
<form class="registration-form" action="login.html"
method="POST">
<h1>Registration</h1>
<label for="full-name">Full Name:</label>
<input type="text" id="full-name" name="full-name"
placeholder="Enter your full name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email"
placeholder="Enter your email" required>
<label for="username">Username:</label>
<input type="text" id="username" name="username"
placeholder="Enter your username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password"
placeholder="Enter your password" required>
<input type="submit" value="Register">
</form>
</body>
</html>
37
Output
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Form</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #f8f9fa;
}
.login-form {
padding: 20px;
38
<label for="password">Password:</label>
<input type="password" id="password" name="password"
placeholder="Enter your password" required>
<input type="submit" value="Login">
</form>
</body>
</html>
Output
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>College/Department Website</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
header {
background-color: #004080;
color: white;
padding: 20px;
text-align: center;
}
nav {
background-color: #ff6666;
padding: 10px;
text-align: center;
}
nav a {
color: white;
margin: 0 10px;
text-decoration: none;
font-size: 18px;
}
41
nav a:hover {
text-decoration: underline;
}
.content {
padding: 20px;
text-align: center;
}
.tutorial-link {
margin-top: 20px;
padding: 10px;
background-color: #004080;
color: white;
text-decoration: none;
border-radius: 5px;
}
.tutorial-link:hover {
background-color: #003060;
}
footer {
background-color: #004080;
color: white;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
42
</style>
</head>
<body>
<header>
<h1>I.K Gujral Punjab Technical University</h1>
<p>Welcome to our official website!</p>
</header>
<nav>
<a href="#about">About Us</a>
<a href="#courses">Courses</a>
<a href="#contact">Contact</a>
</nav>
<div class="content">
<h2>Welcome to Our Tutorials Section</h2>
<p>Enhance your skills with our subject-specific tutorials.</p>
<a href="tutorial.html" class="tutorial-link">Go to Tutorials for Python
</a>
</div>
<footer>
<p>© 2025 I.K. Gujral Punjab Technical University All Rights
Reserved.</p>
</footer>
</body>
</html>
43
Output
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
padding: 20px;
}
input {
padding: 10px;
margin: 10px;
width: 200px;
}
button {
padding: 10px 20px;
margin: 10px;
cursor: pointer;
background-color: #004080;
color: white;
border: none;
border-radius: 5px;
}
button:hover {
background-color: #003060;
}
.result {
margin-top: 20px;
45
font-size: 18px;
color: #333;
}
</style>
</head>
<body>
<h1>Basic Calculator</h1>
<p>Enter two numbers and choose an operation:</p>
<script>
// JavaScript function to perform operations
function performOperation(operation) {
const num1 =
parseFloat(document.getElementById('num1').value);
const num2 =
parseFloat(document.getElementById('num2').value);
let result;
case 'divide':
if (num2 !== 0) {
result = `Division Result: ${num1 / num2}`;
} else {
result = "Cannot divide by zero!";
}
break;
default:
result = "Invalid operation!";
}
}
Output
}
.container {
margin: auto;
padding: 20px;
border: 1px solid #ccc;
background-color: white;
border-radius: 10px;
max-width: 400px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
input {
margin: 10px;
padding: 10px;
width: 80%;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
padding: 10px 20px;
margin: 10px;
background-color: #004080;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
}
button:hover {
50
background-color: #003060;
}
.result {
margin-top: 20px;
font-size: 18px;
color: #333;
}
</style>
</head>
<body>
<div class="container">
<h1>Quadratic Equation Solver</h1>
<p>Enter the coefficients of the quadratic equation (ax² + bx + c = 0):</p>
<button onclick="solveQuadratic()">Solve</button>
<script>
function solveQuadratic() {
51
const a = parseFloat(document.getElementById('a').value);
const b = parseFloat(document.getElementById('b').value);
const c = parseFloat(document.getElementById('c').value);
let result;
if (discriminant > 0) {
const root1 = (-b + Math.sqrt(discriminant)) / (2 * a);
const root2 = (-b - Math.sqrt(discriminant)) / (2 * a);
result = `The roots are real and distinct: Root 1 = ${root1}, Root 2
= ${root2}`;
} else if (discriminant === 0) {
const root = -b / (2 * a);
result = `The roots are real and equal: Root = ${root}`;
} else {
const realPart = -b / (2 * a);
const imaginaryPart = Math.sqrt(-discriminant) / (2 * a);
result = `The roots are complex: ${realPart} + ${imaginaryPart}i
and ${realPart} - ${imaginaryPart}i`;
}
}
52
document.getElementById('result').innerText = result;
}
</script>
</body>
</html>
Output
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Greatest of Three Numbers</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
padding: 20px;
background-color: #f0f8ff;
}
input {
margin: 10px;
padding: 10px;
width: 200px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
padding: 10px 20px;
margin: 10px;
background-color: #004080;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
54
}
button:hover {
background-color: #003060;
}
.result {
margin-top: 20px;
font-size: 18px;
color: #333;
}
</style>
</head>
<body>
<h1>Find the Greatest Number</h1>
<p>Enter three numbers to determine the greatest:</p>
<script>
55
function findGreatest() {
const num1 = parseFloat(document.getElementById('num1').value);
const num2 = parseFloat(document.getElementById('num2').value);
const num3 = parseFloat(document.getElementById('num3').value);
let result;
document.getElementById('result').innerText = result;
}
</script>
</body>
</html>
56
Output
}
button {
padding: 10px 20px;
margin: 10px;
background-color: #004080;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #003060;
}
.result {
margin-top: 20px;
font-size: 18px;
color: #333;
}
</style>
</head>
<body>
<h1>Compute Average and Grade</h1>
<p>Enter marks for 5 subjects:</p>
<button onclick="calculate()">Calculate</button>
<div class="result" id="result"></div>
<script>
// JavaScript function to calculate average and grade
function calculate() {
// Get marks from input fields
const mark1 = parseFloat(document.getElementById('mark1').value);
const mark2 = parseFloat(document.getElementById('mark2').value);
const mark3 = parseFloat(document.getElementById('mark3').value);
const mark4 = parseFloat(document.getElementById('mark4').value);
const mark5 = parseFloat(document.getElementById('mark5').value);
// Determine grade
let grade;
if (average >= 90) {
grade = 'A';
} else if (average >= 80) {
grade = 'B';
} else if (average >= 70) {
grade = 'C';
} else if (average >= 60) {
grade = 'D';
} else {
grade = 'F';
}
document.getElementById('result').innerText = `Average: $
{average.toFixed(2)} \nGrade: ${grade}`;
}
</script>
</body>
</html>
Output
60
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scientific Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
61
}
.calculator {
background: #fff;
border-radius: 10px;
padding: 20px;
box-shadow: 0px 5px 15px rgba(0, 0, 0, 0.2);
}
.display {
width: 100%;
height: 50px;
margin-bottom: 20px;
text-align: right;
padding: 10px;
font-size: 18px;
border: 1px solid #ccc;
border-radius: 5px;
}
.buttons {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
}
button {
padding: 15px;
font-size: 18px;
border: none;
border-radius: 5px;
62
background-color: #004080;
color: white;
cursor: pointer;
}
button:hover {
background-color: #003060;
}
.wide {
grid-column: span 2;
}
</style>
</head>
<body>
<div class="calculator">
<input type="text" id="display" class="display" disabled>
<div class="buttons">
<button onclick="appendValue('7')">7</button>
<button onclick="appendValue('8')">8</button>
<button onclick="appendValue('9')">9</button>
<button onclick="performOperation('/')">/</button>
<button onclick="appendValue('4')">4</button>
<button onclick="appendValue('5')">5</button>
<button onclick="appendValue('6')">6</button>
<button onclick="performOperation('*')">*</button>
<button onclick="appendValue('1')">1</button>
<button onclick="appendValue('2')">2</button>
<button onclick="appendValue('3')">3</button>
63
<button onclick="performOperation('-')">-</button>
<button onclick="appendValue('0')">0</button>
<button onclick="appendValue('.')">.</button>
<button onclick="calculate()">=</button>
<button onclick="performOperation('+')">+</button>
<button onclick="clearDisplay()" class="wide">C</button>
<button onclick="performOperation('sqrt')">√</button>
<button onclick="performOperation('square')">x²</button>
</div>
</div>
<script>
let currentInput = '';
let operator = '';
let operand1 = null;
function appendValue(value) {
currentInput += value;
document.getElementById('display').value = currentInput;
}
function performOperation(op) {
if (op === 'sqrt') {
currentInput = Math.sqrt(parseFloat(currentInput)).toString();
} else if (op === 'square') {
currentInput = (Math.pow(parseFloat(currentInput), 2)).toString();
} else {
64
operand1 = parseFloat(currentInput);
operator = op;
currentInput = '';
}
document.getElementById('display').value = currentInput || operand1;
}
function calculate() {
const operand2 = parseFloat(currentInput);
let result;
switch (operator) {
case '+':
result = operand1 + operand2;
break;
case '-':
result = operand1 - operand2;
break;
case '*':
result = operand1 * operand2;
break;
case '/':
result = operand1 / operand2;
break;
default:
result = parseFloat(currentInput);
}
currentInput = result.toString();
65
document.getElementById('display').value = currentInput;
operator = '';
operand1 = null;
}
function clearDisplay() {
currentInput = '';
operator = '';
operand1 = null;
document.getElementById('display').value = '';
}
</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>Even or Odd Checker</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
padding: 20px;
background-color: #f0f8ff;
}
input {
margin: 10px;
padding: 10px;
width: 200px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
padding: 10px 20px;
background-color: #004080;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
67
}
button:hover {
background-color: #003060;
}
.result {
margin-top: 20px;
font-size: 18px;
color: #333;
}
</style>
</head>
<body>
<h1>Even or Odd Checker</h1>
<p>Enter a number to check whether it is even or odd:</p>
<script>
// JavaScript function to check if the number is even or odd
function checkEvenOdd() {
68
if (isNaN(number)) {
result = "Please enter a valid number!";
} else {
result = (number % 2 === 0) ? `${number} is Even` : `${number} is
Odd`;
}
document.getElementById('result').innerText = result;
}
</script>
</body>
</html>
Output
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prime Number Checker</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
padding: 20px;
background-color: #f0f8ff;
}
input {
margin: 10px;
padding: 10px;
width: 200px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
padding: 10px 20px;
margin: 10px;
background-color: #004080;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
70
}
button:hover {
background-color: #003060;
}
.result {
margin-top: 20px;
font-size: 18px;
color: #333;
}
</style>
</head>
<body>
<h1>Prime Number Checker</h1>
<p>Enter a number to check whether it is prime:</p>
<script>
// JavaScript function to check if the number is prime
function checkPrime() {
71
document.getElementById('result').innerText = result;
}
</script>
</body>
</html>
Output
72
width: 200px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
padding: 10px 20px;
margin: 10px;
background-color: #004080;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
}
button:hover {
background-color: #003060;
}
.result {
margin-top: 20px;
font-size: 18px;
color: #333;
text-align: left;
display: inline-block;
}
</style>
</head>
<body>
<h1>Multiplication Table Generator</h1>
74
<script>
// JavaScript function to generate the multiplication table
function generateTable() {
const number = parseInt(document.getElementById('number').value);
let result = '';
if (isNaN(number)) {
result = "Please enter a valid number!";
} else {
for (let i = 1; i <= 10; i++) {
result += `${number} x ${i} = ${number * i}<br>`;
}
}
document.getElementById('result').innerHTML = result;
}
75
</script>
</body>
</html>
Output
background-color: #f0f8ff;
}
input {
margin: 10px;
padding: 10px;
width: 200px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
padding: 10px 20px;
margin: 10px;
background-color: #004080;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
}
button:hover {
background-color: #003060;
}
.result {
margin-top: 20px;
font-size: 18px;
color: #333;
}
</style>
77
</head>
<body>
<h1>Factorial Calculator</h1>
<p>Enter a number to calculate its factorial:</p>
<script>
// JavaScript function to calculate factorial
function calculateFactorial() {
const number = parseInt(document.getElementById('number').value);
let result;
factorial *= i;
}
result = `The factorial of ${number} is ${factorial}.`;
}
document.getElementById('result').innerText = result;
}
</script>
</body>
</html>
Output
</head>
<body>
<h1>Fibonacci Series Generator</h1>
<p>Click the button below to display the Fibonacci series between 0 and
74:</p>
<script>
// JavaScript function to generate Fibonacci series
function generateFibonacci() {
let fibSeries = [0, 1];
let nextTerm = 0;
Output