Professional Documents
Culture Documents
HTML File 2.0
HTML File 2.0
}
</style>
</head>
<body>
<h1>This is an Embedded CSS Example</h1>
<p>This paragraph is styled using embedded CSS.</p>
</body>
</html>
c) External
<!DOCTYPE html>
<html>
<head>
<title>External CSS Example</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<h1>This is an External CSS Example</h1>
<p>This paragraph is styled using external CSS.</p>
</body>
</html>
CSS file:
h1 {
color: orange;
font-size: 24px;
}
p{
color: brown;
font-size: 18px;
}
NAME: SHIVAM GORLA COURSE: BCA-G1 SEMESTER-4th
ROLLNO: 2221964(67) STUDENT ID-220111410
11: Write a html code to design a web page to implement facebook.com login
page using html and css?
CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Facebook Login</title>
<style>
/* Add a wrapper element to center the login container */
.wrapper {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
}
.login-container {
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
width: 300px;
transition: box-shadow 0.3s; /* Add a transition effect */
}
.login-container h2 {
color: #1877f2;
}
NAME: SHIVAM GORLA COURSE: BCA-G1 SEMESTER-4th
ROLLNO: 2221964(67) STUDENT ID-220111410
.login-container input[type="text"],
.login-container input[type="password"] {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
.login-container input[type="submit"] {
width: 100%;
padding: 10px;
background-color: #1877f2;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="login-container">
<h2><img src="facebook-logo.png" alt="Facebook Logo"></h2>
<form>
<label for="email">Email or Phone</label>
<input type="text" id="email" placeholder="Email or Phone" required
autocomplete="email">
<label for="password">Password</label>
<input type="password" id="password" placeholder="Password" required
autocomplete="current-password">
NAME: SHIVAM GORLA COURSE: BCA-G1 SEMESTER-4th
ROLLNO: 2221964(67) STUDENT ID-220111410
12: Write an HTML code to divide the page into two columns using div tag
with proper margin and border properties. One should display the login page
and other should display text and image?
CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Two Column Layout</title>
<style>
body {
display: flex;
margin: 0;
padding: 0;
height: 100vh;
font-family: Arial, sans-serif;
}
.column {
width: 50%;
padding: 20px;
box-sizing: border-box;
}
.column:nth-child(1) {
border-right: 2px solid #ccc;
}
.login {
max-width: 300px;
margin: auto;
}
NAME: SHIVAM GORLA COURSE: BCA-G1 SEMESTER-4th
ROLLNO: 2221964(67) STUDENT ID-220111410
.login input[type="text"],
.login input[type="password"] {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
.login input[type="submit"] {
width: 100%;
padding: 10px;
background-color: #1877f2;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="column">
<div class="login">
<h2>Login</h2>
<form>
<input type="text" placeholder="Email or Phone" required>
<input type="password" placeholder="Password" required>
<input type="submit" value="Log In">
</form>
</div>
NAME: SHIVAM GORLA COURSE: BCA-G1 SEMESTER-4th
ROLLNO: 2221964(67) STUDENT ID-220111410
</div>
<div class="column">
<h2>Welcome</h2>
<p>This is a sample text.</p>
<img src="https://example.com/sample-image.jpg" alt="Sample Image"
style="width:100%;">
</div>
</body>
</html>
NAME: SHIVAM GORLA COURSE: BCA-G1 SEMESTER-4th
ROLLNO: 2221964(67) STUDENT ID-220111410
13: Write the javascript code to reverse the foreground and background color.
CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Reverse Colors</title>
<style>
body {
background-color: white;
color: black;
text-align: center;
padding: 50px;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
</style>
<script>
function reverseColors(element) {
const currentBgColor = element.style.backgroundColor;
const currentColor = element.style.color;
14: Write the javascript code for showing the use of all the three dialog
boxes(alert, confirm, prompt)
CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dialog Boxes</title>
<style>
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
margin-right: 10px;
}
</style>
</head>
<body>
<h1>JavaScript Dialog Boxes</h1>
<button id="show-alert">Show Alert</button>
<button id="show-confirm">Show Confirm</button>
<button id="show-prompt">Show Prompt</button>
<script>
const showAlertButton = document.getElementById('show-alert');
const showConfirmButton = document.getElementById('show-confirm');
const showPromptButton = document.getElementById('show-prompt');
showAlertButton.addEventListener('click', () => {
showDialog('This is an alert box!', 'alert');
});
showConfirmButton.addEventListener('click', () => {
showDialog('Do you confirm this?', 'confirm');
});
showPromptButton.addEventListener('click', () => {
showDialog('What is your name?', 'prompt');
});
</script>
</body>
</html>
NAME: SHIVAM GORLA COURSE: BCA-G1 SEMESTER-4th
ROLLNO: 2221964(67) STUDENT ID-220111410
CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Form Validation</title>
<style>
.error {
color: red;
font-size: 12px;
margin-top: 5px;
}
</style>
</head>
<body>
<form id="my-form">
<label for="email">Email:</label>
<input type="text" id="email" name="email">
<div class="error" id="email-error"></div>
<button type="submit">Submit</button>
</form>
<script>
const emailInput = document.getElementById('email');
const emailError = document.getElementById('email-error');
function isValidEmail(email) {
const regex = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
NAME: SHIVAM GORLA COURSE: BCA-G1 SEMESTER-4th
ROLLNO: 2221964(67) STUDENT ID-220111410
return regex.test(email);
}
function isValidDigits(digits) {
return digits.length === 4 && /^\d+$/.test(digits);
}
function isValidUsername(username) {
const regex = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$/;
return regex.test(username);
}
function validateForm(event) {
event.preventDefault();
if (!isValidEmail(emailInput.value)) {
emailError.textContent = 'Please enter a valid email address.';
isFormValid = false;
} else {
emailError.textContent = '';
}
if (!isValidDigits(digitsInput.value)) {
digitsError.textContent = 'Please enter exactly 4 digits.';
isFormValid = false;
} else {
digitsError.textContent = '';
NAME: SHIVAM GORLA COURSE: BCA-G1 SEMESTER-4th
ROLLNO: 2221964(67) STUDENT ID-220111410
if (!isValidUsername(usernameInput.value)) {
usernameError.textContent = 'Please enter a valid username.';
isFormValid = false;
} else {
usernameError.textContent = '';
}
if (passwordInput.value.length < 8) {
passwordError.textContent = 'Please enter a password with at least 8 characters.';
isFormValid = false;
} else {
passwordError.textContent = '';
}
if (isFormValid) {
alert('Form submitted successfully!');
}
}
16: Write a php script to validate a student registration form using appropriate
validations as
i) Name field must not be kept empty
ii) Email id should contain @sign
iii) Age field must be greater than 18 years
iv) Check boxes, Radio Buttons must be checked
v) Password filed must contain atleast one capital letter with minimum length 8
and maximum 12
CODE:
<?php
}
return true;
}
// Function to check if a password contains at least one capital letter and has a minimum
length of 8 and maximum length of 12
function isPasswordValid($password) {
if (!preg_match("/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,12}$/", $password)) {
return false;
}
return true;
}
// Validate options
if (!areOptionsSelected($options)) {
echo "Check boxes or Radio Buttons must be checked.<br>";
}