BWD Manual (1) - Removed
BWD Manual (1) - Removed
EXPERIMENT - 7
Solution:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Basic Layout Techniques</title>
<style>
/* Internal CSS */
/* General Styles */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #4CAF50;
color: white;
text-align: center;
padding: 20px 0;
}
.float-nav ul {
list-style: none;
margin: 0;
padding: 0;
}
.float-nav ul li {
float: left;
width: 25%;
}
.float-nav ul li a {
display: block;
color: white;
text-align: center;
padding: 14px;
text-decoration: none;
}
.float-nav ul li {
background-color: #111;
}
.content {
flex: 2;
background-color: #f4f4f4;
padding: 20px;
margin-right: 10px;
}
.sidebar {
flex: 1;
background-color: #e0e0e0;
padding: 20px;
}
<!-- Navigation using Floats with Internal and Inline CSS -->
<nav class="float-nav" style="background-color: #444; overflow: hidden;">
<ul style="padding: 0;">
<li style="float: left; width: 25%;"><a href="#" style="color: white; display: block; padding: 14px; text-
align: center;">Home</a></li>
<li style="float: left; width: 25%;"><a href="#" style="color: white; display: block; padding: 14px; text-
align: center;">About</a></li>
<li style="float: left; width: 25%;"><a href="#" style="color: white; display: block; padding: 14px; text-
align: center;">Services</a></li>
<li style="float: left; width: 25%;"><a href="#" style="color: white; display: block; padding: 14px; text-
align: center;">Contact</a></li>
</ul>
</nav>
<!-- Main Content Section with Flexbox and Inline Styles -->
<main class="flex-container">
<section class="content" style="background-color: #f9f9f9; padding: 25px;">
<h2 style="color: #333;">Welcome to the my world</h2>
<p style="color: #555;">This section my world .</p>
</section>
OUTPUT:
EXPERIMENT - 8
OBJECTIVE :- Create a simple "Hello, World!" script and Use JavaScript to manipulate
HTML elements (change text, styles, attributes)..
Solution:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Element Manipulation</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
background-color: #f0f8ff;
}
#hello-text {
font-size: 24px;
color: #0000ff;
transition: all 0.5s ease;
}
.styled {
color: #ff0000;
background-color: #ffff00;
padding: 10px;
border-radius: 10px;
}
button {
margin: 10px;
padding: 10px 20px;
font-size: 16px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<script>
function changeText() {
document.getElementById("hello-text").innerHTML = "Here this is my world!";
}
function changeStyle() {
const helloText = document.getElementById("hello-text");
helloText.classList.toggle('styled');
}
function changeAttribute() {
const helloText = document.getElementById("hello-text");
helloText.setAttribute("title", "You changed the attribute!");
}
</script>
</body>
</html>
OUTPUT-
Manipulated output-
EXPERIMENT - 9
Solution:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interactive Elements Example</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
background-color: #f7f7f7;
}
h1 {
color: black; /* Set title color to black */
}
#message {
font-size: 24px;
color: #333;
margin: 20px;
transition: all 0.3s ease;
}
.styled {
background-color: #ffeb3b;
color: #ff5722;
padding: 15px;
border-radius: 10px;
}
.hidden {
display: none;
}
button {
margin: 10px;
padding: 10px 20px;
font-size: 16px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
5th SEM BASIC WEB DEVELOPMENT(SBC—C103(P)) 2024-25
IPS ACADEMY, INSTITUTE OF ENGINEERING AND SCIENCE- INDORE
background-color: #45a049;
}
</style>
</head>
<body>
<script>
const messageElement = document.getElementById('message');
document.getElementById('changeTextButton').addEventListener('click', function() {
messageElement.textContent = 'Here this is my world!';
});
document.getElementById('changeStyleButton').addEventListener('click', function() {
messageElement.classList.toggle('styled');
});
document.getElementById('toggleVisibilityButton').addEventListener('click', function() {
messageElement.classList.toggle('hidden');
});
document.getElementById('increaseFontSizeButton').addEventListener('click', function() {
const currentFontSize = parseInt(window.getComputedStyle(messageElement).fontSize);
messageElement.style.fontSize = (currentFontSize + 2) + 'px';
});
</script>
</body>
</html>
OUTPUT
EXPERIMENT - 10
OBJECTIVE :- Implement basic form validation using JavaScript.
Solutiuon:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stylish Form Validation Example</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #e9ecef;
color: #343a40;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
form {
background-color: #ffffff;
padding: 30px;
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
}
h1 {
text-align: center;
margin-bottom: 20px;
color: #007bff;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
.form-group input,
.form-group textarea {
width: 100%;
padding: 10px;
border: 1px solid #ced4da;
border-radius: 5px;
transition: border-color 0.3s;
}
.form-group input:focus,
.form-group textarea:focus {
border-color: #007bff;
outline: none;
}
.form-group .error {
color: #d9534f;
font-size: 0.9em;
margin-top: 5px;
}
.btn-submit {
width: 100%;
padding: 10px;
font-size: 1em;
border: none;
border-radius: 5px;
background-color: #007bff;
color: white;
cursor: pointer;
transition: background-color 0.3s;
margin-top: 10px;
}
.btn-submit:hover {
background-color: #0056b3;
}
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<div class="error" id="nameError"></div>
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<div class="error" id="emailError"></div>
</div>
<div class="form-group">
<label for="age">Age:</label>
<input type="number" id="age" name="age" min="1" max="120" required>
<div class="error" id="ageError"></div>
</div>
<div class="form-group">
<label for="message">Message:</label>
<textarea id="message" name="message" rows="4" required></textarea>
5th SEM BASIC WEB DEVELOPMENT(SBC—C103(P)) 2024-25
IPS ACADEMY, INSTITUTE OF ENGINEERING AND SCIENCE- INDORE
<script>
document.getElementById('contactForm').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent form submission
// Validate name
if (name === '') {
document.getElementById('nameError').textContent = 'Name is required.';
isValid = false;
}
// Validate email
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (email === '' || !emailPattern.test(email)) {
document.getElementById('emailError').textContent = 'Enter a valid email address.';
isValid = false;
}
// Validate age
if (age === '' || age < 1 || age > 120) {
document.getElementById('ageError').textContent = 'Enter a valid age between 1 and 120.';
isValid = false;
}
// Validate message
if (message === '') {
document.getElementById('messageError').textContent = 'Message is required.';
isValid = false;
}
OUTPUT