MONALISHA
MONALISHA
GREATER NOIDA-201306
(An Autonomous Institute)
Information Technology
Session (2023–2024)
LAB FILE
OF
WEB TECHNOLOGY LAB
(ACSE0555)
(5thSemester)
Submitted to:
Submitted by :
Ms. Rohini Sharma (Asst. Professor) Monalisha Aggarwal
(2201330139013)
Ms. Neetu Rajput (Asst. Professor)
Code:
<!DOCTYPE html>
<html>
<head>
<title>My CV and Websites</title>
</head>
<body>
<h1>My CV and Websites</h1>
<h2>CV</h2>
<a href="name1.html" target="_blank">View My CV</a>
<h2>Institute Website</h2>
<a href="https://www.niet.co.in/syllabus.php" target="_blank">Visit Institute Website</a>
<h2>Department Website</h2>
<a href="https://www.niet.co.in/btech-information-technology.php" target="_blank">Visit
Department Website</a>
</body>
</html>
Program 2.
Write a program in XML for creation of DTD, which specifies set of rules.
Create a style sheet in CSS/ XSL & display the document in internet explorer.
Code:
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
body {
font-family: Arial, sans-serif; background-color: #f2f2f2;
}
h1 {
color: #333;
text-align: center;
}
p{
color: #666;
line-height: 1.5;
}
.note {
border: 1px solid #ccc; padding: 10px;
margin-bottom: 20px;
}
.note p {
margin-bottom: 5px;
}
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="note">
<div class="note">
<h2><xsl:value-of select="heading"/></h2>
<p><strong>To:</strong> <xsl:value-of select="to"/></p>
<p><strong>From:</strong> <xsl:value-of select="from"/></p>
<p><xsl:value-of select="body"/></p>
</div>
</xsl:template>
</xsl:stylesheet>
Output:
Program 3.
Write a program to show the use of XML Schema.
Code:
<!DOCTYPE html>
<html>
<head>
<title>Book Details</title>
<link rel="stylesheet" type="text/css" href="style1.css">
</head>
<body>
<h1>Book Details</h1>
<table>
<tr>
<th>Title</th>
<th>Author</th>
<th>Year</th>
</tr>
<xsl:for-each select="books/book">
<tr>
<td><xsl:value-of select="title"/>Harry Potter and the Philosopher's Stone</td>
<td><xsl:value-of select="author"/>J.K. Rowling</td>
<td><xsl:value-of select="year"/>1997</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>}
Code:
<!DOCTYPE html>
<html>
<head>
<title>CSS Program</title>
<style>
/* Inline CSS */ h1 {
color: red;
font-size: 24px;
}
</style>
<style>
/* Internal CSS */ p {
color: blue; font-size: 18px;
}
</style>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<h1 style="color: green; font-size: 30px;">This is an example of inline CSS</h1>
<p>This is an example of internal CSS.</p>
<p>This is an example of external CSS.</p>
</body>
</html>
Output:
Program 5.
Write a program for CSS Box Model.
Code:
<!DOCTYPE html>
<html>
<head>
<title>CSS Box Model</title>
<style>
.box {
width: 200px; height: 200px;
border: 1px solid black; padding: 20px;
margin: 20px;
}
</style>
</head>
<body>
<div class="box">
This is a box element.
</div>
</body>
</html>
Output:
Program 6 .
Write a program to show the use of Bootstrap components and Grid System .
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<title>Bootstrap Components and Grid System</title>
</head>
<body>
<div class="container">
<h1>Bootstrap Components and Grid System</h1>
<div class="row">
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Card Title</h5>
<p class="card-text">This is a sample card with some text content.</p>
<a href="#" class="btn btn-primary">Read More</a>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Card Title</h5>
<p class="card-text">This is another sample card with some text content.</p>
<a href="#" class="btn btn-primary">Read More</a>
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
Output:
Program 7.
Write HTML program to design Registration form and validate it using
JavaScript.
Code:
<!DOCTYPE html>
<html>
<head>
<title>Registration Form</title>
<style>
.container {
width: 400px; margin: 0 auto; padding: 20px;
border: 1px solid #ccc; border-radius: 5px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label { display: block; font-weight: bold;
margin-bottom: 5px;
}
.form-group input { width: 100%; padding: 10px;
border: 1px solid #ccc; border-radius: 5px;
}
.error-message { color: red;
font-size: 12px;
}
</style>
<script>
function validateForm() {
var name = document.forms["registrationForm"]["name"].value; var email =
document.forms["registrationForm"]["email"].value;
var password = document.forms["registrationForm"]["password"].value;
var confirmPassword = document.forms["registrationForm"]["confirmPassword"].value;
if (name == "") {
alert("Name must be filled out"); return false;
}
if (email == "") {
alert("Email must be filled out"); return false;
}
if (password == "") {
alert("Password must be filled out"); return false;
}
if (confirmPassword == "") {
alert("Confirm Password must be filled out"); return false;
}
Output:
Program 8.
Write JavaScript program to show the use of Dialogue Boxes i.e. Alert,
Confirm and Prompt Boxes.
Code:
<!DOCTYPE html>
<html>
<head>
<title>Dialogue Boxes</title>
<style> body {
font-family: Arial, sans-serif; text-align: center;
}
</style>
</head>
<body>
<h1>Dialogue Boxes</h1>
<script>
// Alert Box
alert("This is an alert box!");
// Confirm Box
var result = confirm("Are you sure you want to proceed?"); if (result) {
alert("You clicked OK!");
} else {
alert("You clicked Cancel!");
}
// Prompt Box
var name = prompt("Please enter your name:"); if (name) {
alert("Hello, " + name + "!");
} else {
alert("You did not enter a name!");
}
</script>
</body>
</html>
Output:
Program 9.
Write a program to show various types of JavaScript Events.
Code:
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Events</title>
<style>
.event {
padding: 10px;
margin-bottom: 10px; background-color: #f2f2f2; border: 1px solid #ccc;
}
</style>
</head>
<body>
<h1>JavaScript Events</h1>
<script>
function changeColor() {
document.getElementById("colorDiv").style.backgroundColor = "red";
}
</script>
Output:
Program 10.
Write a program in PHP to find the factorial of given number.
Code:
<?php
function factorial($number) { if ($number <= 1) {
return 1;
} else {
return $number * factorial($number - 1);
}
}
$factorial = factorial($number);
?>
<!DOCTYPE html>
<html>
<head>
<title>Factorial Calculator</title>
<style>
body {
font-family: Arial, sans-serif; background-color: #f2f2f2;
}
.container {
max-width: 500px; margin: 0 auto; padding: 20px;
background-color: #fff; border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center; margin-bottom: 20px;
}
p{
text-align: center; font-size: 18px;
margin-bottom: 10px;
}
.result {
text-align: center; font-size: 24px; font-weight: bold; color: #333;
}
</style>
</head>
<body>
<div class="container">
<h1>Factorial Calculator</h1>
<p>Calculating factorial of <?php echo $number; ?>:</p>
<p class="result"><?php echo $factorial; ?></p>
</div>
</body>
</html>
Output:
Program 11.
Write a program in PHP to perform file handling.
Code:
<?php
?>
<html>
<head>
<style>
body {
font-family: Arial, sans-serif; background-color: #f2f2f2;
}
.container {
max-width: 800px; margin: 0 auto; padding: 20px;
background-color: #fff; border: 1px solid #ccc;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
color: #333;
text-align: center;
}
p{
color: #666;
line-height: 1.5;
}
</style>
</head>
<body>
<div class='container'>
<h1>File Contents</h1>
<p><?php echo $contents;?></p>
</div>
</body>
</html>
Output:
Program 12.
Write a PHP program to show the use of Session & Cookies.
Code:
<?php
// Start the session session_start();
// Set a cookie
setcookie('language', 'English', time() + (86400 * 30), '/');
<!DOCTYPE html>
<html>
<head>
<title>Session & Cookies Example</title>
<style>
body {
font-family: Arial, sans-serif; background-color: #f2f2f2;
}
.container {
max-width: 500px; margin: 0 auto;
padding: 20px;
background-color: #fff; border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center; color: #333;
}
p{
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>Session & Cookies Example</h1>
<p>Session Username: <?php echo $_SESSION['username']; ?></p>
<p>Cookie Language: <?php echo $_COOKIE['language']; ?></p>
</div>
</body>
</html>
Output: