Web Lab Manual
Web Lab Manual
Table of Contents
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First Web Page</title>
</head>
<body>
<h1>This is Heading 1</h1>
<h2>This is Heading 2</h2>
<h3>This is Heading 3</h3>
<h4>This is Heading 4</h4>
<h5>This is Heading 5</h5>
<h6>This is Heading 6</h6>
<marquee>Basic HTML Tags</marquee>
<p>
Here are examples of logical styles:<br>
<b>Bold text</b><br>
<i>Italic text</i><br>
<u>Underlined text</u><br>
<strong>Strong text</strong><br>
<em>Emphasized text</em><br>
Text with <sub>subscript</sub> and <sup>superscript</sup>
</p>
</body>
</html>
OUTPUT:
2. Develop the HTML page named as “Table.html” to display your class time
table.
a) Provide the title as Time Table with table header and table footer, row-span
and col-span etc.
b) Provide various colour options to the cells (Highlight the lab hours and
elective hours with different colours.)
c) Provide colour options for rows.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Time Table</title>
</head>
<body>
<h1 style="text-align: center;">Time Table</h1>
<tbody>
<tr>
<td style="background-color: lightblue;">Monday</td>
<td>Math</td>
<td>Physics</td>
<td style="background-color: lightcoral;" colspan="2">Lab</td>
<td rowspan="5" style="background-color: lightyellow;">Lunch Break</td>
<td>English</td>
</tr>
<tr>
OUTPUT:
3. Develop an external style sheet named as “style.css” and provide different styles
for h2, h3, hr, p, div, span, time, img & a tags. Apply different CSS selectors for
tags and demonstrate the significance of each.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Styling sheet</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<main id="main-content">
<h2>Welcome to Our Styled Page</h2>
style.css file
/* Element Selector */
h2 {
color: #2c3e50;
font-family: 'Arial', sans-serif;
border-bottom: 2px solid #3498db;
padding-bottom: 10px;
}
/* Element Selector with Pseudo-class */
h3:hover {
color: #e74c3c;
cursor: pointer;
/* ID Selector */
#main-content {
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #c5f4cf;
}
/* Descendant Selector */
div p {
line-height: 1.6;
margin-bottom: 15px;
}
/* Child Selector */
div > span {
font-weight: bold;
color: #16a085;
}
}
/* Multiple Selectors */
img, a {
border: 1px solid #bdc3c7;
padding: 5px;
width:400px;
}
/* Pseudo-class Selector for Links */
a:link, a:visited {
color: #dd10f4;
text-decoration: none;
}
a:hover, a:active {
color: #e74c3c;
text-decoration: underline;
}
/* Attribute Selector for Images */
img[alt] {
max-width: 100%;
height: auto;
}
/* Combining Selectors */
div.special p {
text-indent: 20px;
color: #27ae60; }
OUTPUT:
/* Body styling */
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff;
color: #333;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
/* Form styling */
.registration-form {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
}
h2 {
color: #4CAF50;
font-size: 24px;
margin-bottom: 15px;
}
table {
width: 100%;
}
td {
padding: 8px;
font-size: 16px;
color: #333;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 14px;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
border: none;
padding: 10px 20px;
font-size: 16px;
border-radius: 4px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
/* Styling labels */
label {
font-weight: bold;
}
</style>
</head>
<body>
<div class="registration-form">
<h2>Registration Form</h2>
<form action="#" method="post">
<table>
<tr>
<td><label for="name">Full Name:</label></td>
<td><input type="text" id="name" name="name" required></td>
</tr>
<tr>
<td><label for="email">Email:</label></td>
<td><input type="email" id="email" name="email" required></td>
</tr>
<tr>
<td><label for="password">Password:</label></td>
<td><input type="password" id="password" name="password" required></td>
</tr>
<tr>
<td><label for="dob">Date of Birth:</label></td>
<td><input type="date" id="dob" name="dob"></td>
</tr>
<tr>
<td><label for="State">State:</label></td>
<td>
<select id="state" name="State">
<option value="Maharashtra">Maharashtra</option>
<option value="Karnataka">Karnataka</option>
<option value="Tamil Nadu">Tamil Nadu</option>
</select>
</td>
</tr>
<tr>
<td><label for="gender">Gender:</label></td>
<td>
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label>
OUTPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Newspaper</title>
<style>
/* General page styling */
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0;
padding: 0;
background-color: #f0f0f0;
color: #333;
}
/* Header styling */
header {
background-color: #333;
color: #fff;
padding: 1em;
text-align: center;
}
/* Footer styling */
footer {
background-color: #333;
color: #fff;
padding: 1em;
text-align: center;
font-size: 0.9em;
}
/* Section styling */
section {
padding: 2em;
background-color: #fff;
margin: 1em;
}
/* Article styling */
article {
background-color: #e3f2fd;
color: #0056b3;
padding: 1em;
margin-bottom: 1em;
border-radius: 8px;
}
/* Aside styling */
aside {
background-color: #ffeb3b;
color: #333;
padding: 1em;
margin: 1em;
border-radius: 8px;
}
/* Figure styling */
figure {
margin: 1em 0;
text-align: center;
}
figure img {
width: 100%;
max-width: 300px;
border: 2px solid #333;
}
figcaption {
font-size: 0.9em;
color: #555;
}
/* Table styling */
table {
width: 100%;
border-collapse: collapse;
margin: 1em 0;
}
th, td {
padding: 0.5em;
text-align: left;
border: 1px solid #ddd;
}
th {
background-color: #2196f3;
color: #fff;
}
</style>
</head>
<body>
<aside>
<h4>Did You Know?</h4>
<p>Many tech companies are investing heavily in AI to stay ahead in the market. AI is expected
to transform industries globally.</p>
</aside>
</section>
</body>
</html>
OUTPUT:
6. Apply HTML, CSS and JavaScript to design a simple calculator to perform the
following operations: sum, product, difference, remainder, quotient, power,
square-root and square.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Calculator</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
height: 1000px;
font-family: Arial, sans-serif;
background-color: #f0f0f0;
background-color: antiquewhite;
}
.calculator {
width: 400px;
height:630px;
background-color: #fff;
padding: 10px;
border-radius: 8px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 1);
}
#display {
width: 100%;
height: 100px;
font-size: 40px;
text-align: right;
margin-bottom: 10px;
border: 5px solid #080808;
padding: 5px;
border-radius: 5px;
.buttons {
display: grid;
height:500px;
grid-template-columns: repeat(4, 1fr);
gap: 5px;
}
button {
padding: 10px;
font-size: 38px;
background-color: #e0e0e0;
border-radius: 5px;
cursor: pointer;
border: 1px solid black;
}
button:hover {
background-color: #d0d0d0;
}
button:active {
background-color: #c0c0c0;
}
.zero {
grid-column: span 3;
}
</style>
</head>
<body>
<div class="calculator">
<input type="text" id="display" placeholder="0" disabled>
<div class="buttons">
<button onclick="clearDisplay()">C</button>
<button onclick="appendOperator('/')">/</button>
<button onclick="appendOperator('*')">*</button>
<button onclick="deleteLast()">DEL</button>
<button onclick="appendNumber('7')">7</button>
<button onclick="appendNumber('8')">8</button>
<button onclick="appendNumber('9')">9</button>
<button onclick="appendOperator('-')">-</button>
<button onclick="appendNumber('4')">4</button>
<button onclick="appendNumber('5')">5</button>
<button onclick="appendNumber('6')">6</button>
<button onclick="appendOperator('+')">+</button>
<button onclick="appendNumber('1')">1</button>
<button onclick="appendNumber('2')">2</button>
<button onclick="appendNumber('3')">3</button>
<button onclick="calculate()">=</button>
<button onclick="appendNumber('0')" class="zero">0</button>
<button onclick="appendNumber('.')">.</button>
<button onclick="power()">x<sup>y</sup></button>
<button onclick="squareRoot()">√</button>
<button onclick="square()">x<sup>2</sup></button>
<button onclick="remainder()">%</button>
</div>
</div>
</body>
<script>
const display = document.getElementById('display');
Output:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JSON Utility Program</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: #f4f4f4;
}
.container {
max-width: 800px;
margin: auto;
padding: 20px;
background: white;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
}
textarea, input {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
display: inline-block;
background-color: #4CAF50;
color: white;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
margin-right: 10px;
}
button:hover {
background-color: #45a049;
}
.result {
background: #e7e7e7;
padding: 10px;
border-radius: 4px;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>JSON Utility Program</h1>
<script>
// a) Convert JSON Text to JavaScript Object
function convertJsonToObject() {
try {
const jsonInput = document.getElementById('jsonInput').value;
const jsObject = JSON.parse(jsonInput);
document.getElementById('result').innerText = 'JavaScript Object:\n' +
JSON.stringify(jsObject, null, 2);
} catch (error) {
document.getElementById('result').innerText = 'Error: ' + error.message;
}
}
function convertJsonToCsv() {
try {
const jsonInput = document.getElementById('dataInput').value;
const jsObject = JSON.parse(jsonInput); // Parse JSON string into a JavaScript object
function convertCsvToJson() {
try {
const csvInput = document.getElementById('dataInput').value;
const lines = csvInput.split('\n'); // Split by line
const headers = lines[0].split(','); // First line contains headers
Output:
8.
a. Develop a PHP program (with HTML/CSS) to keep track of the number of
visitors visiting the web page and to display this count of visitors, with
relevant headings.
b. Develop a PHP program (with HTML/CSS) to sort the student records
which are stored in the database using selection sort.
visitor_count.php
<?php
$filename = "counter.txt";
if (!file_exists($filename)) {
file_put_contents($filename, 0);
}
$visitorCount = (int) file_get_contents($filename);
$visitorCount++;
file_put_contents($filename, $visitorCount);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Visitor Counter</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
background-color: #f5f5f5;
margin-top: 50px;
}
.counter-container {
background: #ffffff;
border: 2px solid #ccc;
padding: 20px;
display: inline-block;
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
}
h1 {
color: #333;
}
p{
font-size: 18px;
color: #555;
}
</style>
</head>
<body>
<div class="counter-container">
<h1>Welcome to Our Website!</h1>
<p>You are visitor number: <strong><?php echo $visitorCount; ?></strong></p>
</div>
</body>
</html>
Output:
student_record.php
<?php
// db_config.php
$host = 'localhost';
$dbname = 'student_db';
$username = 'root';
$password = '';
// Check connection
if ($conn->connect_error) {
die("Database connection failed: " . $conn->connect_error);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sorted Student Records</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
margin: 20px;
}
table {
width: 60%;
margin: 0 auto;
border-collapse: collapse;
background: #ffffff;
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
}
th, td {
padding: 10px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #f4b400;
color: white;
}
tr:hover {
background-color: #f1f1f1;
}
</style>
</head>
<body>
<h1 style="text-align: center;">Student Records (Sorted by Marks)</h1>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Marks</th>
</tr>
</thead>
<tbody>
<?php foreach ($students as $student): ?>
<tr>
<td><?php echo htmlspecialchars($student['id']); ?></td>
<td><?php echo htmlspecialchars($student['name']); ?></td>
<td><?php echo htmlspecialchars($student['marks']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>
Output:
9. Develop jQuery script (with HTML/CSS) for: a. Appends the content at the
end of the existing paragraph and list. b. Change the state of the element with
CSS style using animate() method c. Change the color of any div that is animated.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery Task</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
padding: 0;
background-color: #f9f9f9;
}
.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
background: #fff;
border: 1px solid #ddd;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
p, ul {
margin: 10px 0;
}
button {
margin: 10px 5px;
padding: 8px 15px;
background-color: #007bff;
color: #fff;
border: none;
cursor: pointer;
border-radius: 4px;
}
button:hover {
background-color: #0056b3;
}
.box {
width: 100px;
height: 100px;
$(document).ready(function () {
// a. Append content to paragraph and list
$('#append-btn').click(function () {
$('p').append(' This is appended content.');
$('ul').append('<li>New appended item</li>');
});
</script>
</body>
</html>
Output:
10. Develop a JavaScript program with Ajax (with HTML/CSS) for: a. Use ajax()
method (without Jquery) to add the text content from the text file by sending ajax
request. b. Use ajax() method (with Jquery) to add the text content from the text
file by sending ajax request. c. Illustrate the use of getJSON() method in jQuery
d. Illustrate the use of parseJSON() method to display JSON values.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AJAX with JavaScript and jQuery</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
padding: 20px;
}
.container {
max-width: 600px;
margin: auto;
background: #ffffff;
padding: 20px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
button {
padding: 10px 15px;
margin: 10px 0;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
pre, p {
background-color: #f9f9f9;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="container">
<h1>AJAX Demo</h1>
<button id="ajax-js">Load Text (JavaScript AJAX)</button>
<p id="content-js"></p>
});
</script>
</body>
</html>
data.json
{
"name": "John Doe",
"age": 30,
"location": "New York"
}
data.txt
This is text to show output
Output: