Experiment 3 HTML CSS JS (1)
Experiment 3 HTML CSS JS (1)
Experiment 3 HTML CSS JS (1)
Objective
Prerequisites
- Any text editor (VS Code, Sublime Text, or Notepad++)
- Web browser (Chrome or Firefox recommended)
- Basic understanding of web development concepts
mkdir web_basics_experiment
cd web_basics_experiment
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Information Form</title>
</head>
<body>
<header>
<h1>Student Information</h1>
</header>
<main>
<form id="studentForm">
<div class="form-group">
<label for="name">Full Name:</label>
<input type="text" id="name" required>
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" required>
</div>
<div class="form-group">
<label for="course">Course:</label>
<select id="course">
<option value="web">Web Development</option>
<option value="python">Python Programming</option>
<option value="java">Java Programming</option>
</select>
</div>
<div class="form-group">
<label>Gender:</label>
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label>
</div>
<button type="submit">Submit</button>
<button type="reset">Reset</button>
</form>
<div id="output">
<h2>Submitted Information</h2>
<p id="result"></p>
</div>
</main>
<footer>
<p>© 2024 Web Development Lab</p>
</footer>
</body>
</html>
/* Basic Reset */
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
line-height: 1.6;
padding: 20px;
background-color: f0f0f0;
}
header {
text-align: center;
margin-bottom: 30px;
color: 333;
}
main {
max-width: 600px;
margin: 0 auto;
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.form-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
color: 555;
}
input[type="text"],
input[type="email"],
select {
width: 100%;
padding: 8px;
border: 1px solid ddd;
border-radius: 4px;
}
input[type="radio"] {
margin-right: 5px;
}
button {
background-color: 4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
margin-right: 10px;
}
button[type="reset"] {
background-color: f44336;
}
button:hover {
opacity: 0.8;
}
output {
margin-top: 20px;
padding: 15px;
border-top: 1px solid ddd;
}
footer {
text-align: center;
margin-top: 30px;
color: 666;
}
<script src="script.js"></script>
document.addEventListener('DOMContentLoaded', function() {
const studentForm = document.getElementById('studentForm');
const resultDiv = document.getElementById('result');
studentForm.addEventListener('submit', function(e) {
e.preventDefault();
// Validate form
if (!name || !email || !gender) {
alert('Please fill in all fields!');
return;
}
// Display results
const output = `
<strong>Name:</strong> ${name}<br>
<strong>Email:</strong> ${email}<br>
<strong>Course:</strong> ${courseName}<br>
<strong>Gender:</strong> ${gender.value}
`;
resultDiv.innerHTML = output;
Required Screenshots
1. For HTML Structure (Experiment 1):
- Screenshot of raw HTML page without CSS
- Name as: `exp1_html.png`
Submission Format
1. Create a ZIP file named `Web_Basics_Experiment_<YourName>` containing:
- All source code files (`index.html`, `styles.css`, `script.js`)
- All required screenshots
- A readme.txt file containing:
- Your name and experiment date
- Browser used and version
- Any issues encountered and solutions
Validation Checklist
Before submitting, verify:
- HTML form displays all elements correctly
- CSS styling matches the expected output
- JavaScript validation works for empty fields
- Form submission displays data correctly
- Reset button clears all fields
- All screenshots are clear and complete
- All files are named correctly
Remember: Document any unique issues and their solutions in your readme.txt file.