Web Technology
Web Technology
Lab Manual
1. WAP in HTML for displaying a form using checkboxes and radio buttons.
Program –
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form with Checkboxes and Radio Buttons</title>
</head>
<body>
<h2>Form Example with Checkboxes and Radio Buttons</h2>
<form action="#">
3. WAP code to create a Home Page having two links: About Us, Our Services.
Program –
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Page</title>
</head>
<body>
<h1>Welcome to Our Website</h1>
<ul>
<li><a href="aboutus.html">About Us</a></li>
<li><a href="services.html">Our Services</a></li>
</ul>
</body>
</html>
Output –
4. WAP for displaying a flower image in HTML document.
Program –
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flower Image</title>
</head>
<body>
<h1>Beautiful Flower</h1>
<img src="https://cdn2.stylecraze.com/wp-content/uploads/2013/10/1668-Top-
25-Beautiful-Orchid-Flowers-is.jpg.avif" alt="Flower" width="200">
</body>
</html>
Output –
5. WAP code to display your education details in a tabular format.
Program –
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Education Details</title>
<style>
table {
width: 50%;
border-collapse: collapse;}
th, td {
border: 1px solid black; padding: 8px;
text-align: center;}
th {
background-color: #f2f2f2;}
</style>
</head>
<body>
<h2>Education Details</h2>
<table>
<tr>
<th>Degree</th>
<th>Institution</th>
<th>Year</th>
</tr>
<tr>
<td>Bachelor's in Computer Science</td>
<td>XYZ University</td>
<td>2018 - 2022</td>
</tr>
<tr>
<td>High School</td>
<td>ABC School</td>
<td>2016 - 2018</td>
</tr>
</table>
</body>
</html>
Output –
<div class="bordered" style="width: 300px; height: 200px;"> This element has a border
image.
</div>
</body>
</html>
Output –
8. WAP code to set all the border properties in one CSS declaration.
Program –
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shorthand Border Properties</title>
<style>
.bordered-box {
border: 5px solid #4CAF50; /* width, style, and color */ padding: 20px;
width: 300px;
}
</style>
</head>
<body>
<h2>Box with All Border Properties in One Declaration</h2>
<div class="bordered-box">
This box has a border with all properties set in one declaration.
</div>
</body>
</html>
Output –
9. WAP code to create a frameset having a header, navigation, and content section with the
help of CSS.
Program –
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
body {
display: flex;
flex-direction: column; height: 100vh;
}
header {
background-color: #4CAF50; color: white;
padding: 15px; text-align: center;
}
nav {
background-color: #333; color: white;
padding: 15px; width: 20%;
height: 100%; position: fixed;
top: 60px; /* Adjust according to header height */
}
main {
margin-left: 20%; /* Make space for the nav */ padding: 20px;
height: 100%; overflow-y: auto;
}
</style>
</head>
<body>
<header>
<h1>Website Header</h1>
</header>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<main>
<h2>Main Content Area</h2>
<p>This is where the main content will be displayed.</p>
</main>
</body>
</html>
Output –
10. WAP code to create rounded corners by using CSS.
Program –
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rounded Corners</title>
<style>
.rounded-box { width: 300px; height: 200px;
background-color: #4CAF50; color: white;
padding: 20px;
border-radius: 15px; /* This property creates rounded corners */ text-align: center;
}
</style>
</head>
<body>
<h2>Element with Rounded Corners</h2>
<div class="rounded-box">
This box has rounded corners.
</div>
</body>
</html>
Output –
<script>
function displayMessage() {
document.getElementById('output').innerHTML = "Hii, Bhim Singh"
}
displayMessage();
15. Write a JS code to store multiple values in a single variable using an array.
Program –
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Array Example</title>
</head>
<body>
<script>
// Create an array to store multiple values
let colors = ["Red", "Green", "Blue", "Yellow", "Purple"];
// Display the array contents
alert("Array contents: " + colors.join(", "));
</script>
</body>
</html>
Output –
16. Write a program to display the Date object in JavaScript.
Program –
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Date Object Example</title>
</head>
<body>
<script>
// Create a new Date object
let currentDate = new Date();
Output –
17. Write a program to reverse a string in JavaScript.
Program –
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reverse a String</title>
</head>
<body>
<script>
function reverseString(str) {
return str.split("").reverse().join("");
}
let originalString = "Hello World!";
let reversedString = reverseString(originalString);
alert("Original String: " + originalString + "\nReversed String: " + reversedString);
</script>
</body>
</html>
Output –
Output –
19. Write a program to add an event handler to a particular element.
Program –
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Event Handler Example</title>
</head>
<body>
<button id="myButton">Click Me!</button>
<script>
// Adding an event handler to the button
document.getElementById("myButton").addEventListener("click", function() {
alert("Button clicked!");
});
</script>
</body>
</html>
Output –
20. Write a CSS code to set the text color for different elements.
Program –
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text Color Styling</title>
<style>
/* Setting the text color for different elements */ body {
color: #333; /* Default text color for body */
}
h1 {
color: red; /* Red text color for h1 */
}
p{
color: green; /* Green text color for paragraph */
}
.important-text {
color: blue; /* Blue color for elements with class 'important-text' */
}
</style>
</head>
<body>
<h1>This is a Heading (Red)</h1>
<p>This is a paragraph (Green)</p>
<p class="important-text">This is some important text (Blue)</p>
</body>
</html>
Output –