Weblab
Weblab
Solution:
<!DOCTYPE html>
<html lang="en">
<head>
<title>skeleton of html</title>
</head>
<body>
<h1>Structure of HTML</h1>
<p>Welcome everyone</p>
</body>
</html>
Output:
2. Write HTML code to make a set of menus with links to multiple page.
Solution:
<html lang="en">
<head>
<title>links to multiple pages</title>
</head>
<body>
<h1>links</h1>
<a href="question1.html">HTML</a>
<a href="abouthtml.html">About IT</a>
<a href="use.html">uses</a>
</body>
</html>
Output:
Solution:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Table</title>
</head>
<body>
<caption><b>SwastikTable</b></caption>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="3"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td rowspan="2"></td>
<td></td>
<td></td>
<td rowspan="2"></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>
Output:
4. Prepare a login form with username and password.
Solution:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Login form</title>
<style>
h1{
color:white;
font-size:22px;
background-color:green;
text-align:center;
}
</style>
</head>
<body>
<h1>HTML FORM</h1>
<form action="" method="POST">
Username:<input type="text" name="user"><br><br>
Password:<input type="password" name="pass"><br><br>
<input type="submit" value="login">
<input type="reset" value="reset">
</form>
</body>
</html>
Output:
Output:
8. Prepare a login form with username and password and validate it using client
side script.
<!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>
</head>
<body>
<form id="loginForm" onsubmit="return
validateForm()">
<h2>Login Form</h2>
<div>
<label for="username">Username:</label>
<input type="text" id="username" name="username"
required>
<span id="usernameError"></span>
</div>
<div>
<label for="password">Password:</label>
<input type="password" id="password"
name="password" required>
<span id="passwordError"></span>
</div>
<br>
<input type="submit" value="Login">
</form>
<script>
function validateForm() {
let username =
document.getElementById('username').value;
let password =
document.getElementById('password').value;
let usernameError =
document.getElementById('usernameError');
let passwordError =
document.getElementById('passwordError');
usernameError.innerText = "";
passwordError.innerText = "";
// Basic validation checks
if (username === "") {
usernameError.innerText = "Username cannot be
empty";
return false;
}
12. Show three different ways to write/insert CSS into the HTML document.
Inline Styles
<div style="background-color: red; width: 200px; height: 100px;">This is a red
box.</div>
Internal Stylesheet
<html>
<head>
<title>My Page</title>
<style>
.red-box {
background-color: red;
width: 200px;
height: 100px;
}
</style>
</head>
<body>
<div class="red-box">This is a red box.</div>
</body>
</html>
External Stylesheet
<html>
<head>
<title>My Page</title>
<link rel="stylesheet" href="styles.css"> </head>
<body>
<div class="red-box">This is a red box.</div>
</body>
</html>
styles.css
.red-box {
background-color: red;
width: 200px;
height: 100px;
}
13. Prepare a XML document to list students with their; name, grade, rollno and
address.
14. Write javascript and HTML to validate a form with field first name and last
name.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form Validation</title>
</head>
<body>
<h2>Sample Form</h2>
<form id="sampleForm" onsubmit="return validateForm()">
<label for="firstName">First Name:</label>
<input type="text" id="firstName" name="firstName"><br><br>
<label for="lastName">Last Name:</label>
<input type="text" id="lastName" name="lastName"><br><br>
<input type="submit" value="Submit">
</form>
<p id="errorMessage" style="color:red;"></p>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.getElementById('sampleForm');
form.addEventListener('submit', function(event) {
if (!validateForm()) {
event.preventDefault(); // Prevent form submission
}
});
});
function validateForm() {
// Get the form elements
const firstName = document.getElementById('firstName').value.trim();
const lastName = document.getElementById('lastName').value.trim();
const errorMessage = document.getElementById('errorMessage');
// If validation passed
return true;
}
</script>
</body>
</html>
15. Prepare an HTML form to upload a file and write server (PHP) side script to upload it to a
16. Write an HTML document along with necessary CSS to design a circle.
17. Prepare a XML document to store a restaurant menu with the element names;
18. Write a server side code to read content from a hello.txt file.
19. Prepare a contact form with Name, Email, Phone, Country and Message fields and
20. Write a server side script to store and read the cookie.
21. Prepare a login form with username and password, then check entered username and
Database: admin