Komya Cs
Komya Cs
Komya Cs
516
BA (H) ENGLISH
GE-Introduction to
web programming
HTML
Q1)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Formatting Example</title>
<style>
body {
background-color: blue;
h1 {
color: navy;
font-size: 24px;
font-weight: bold;
text-decoration: underline;
p{
color: yellow;
font-style: italic;
font-size: 18px;
}
.underline {
text-decoration: underline;
</style>
</head>
<body>
<h1>MY WEBPAGE</h1>
<hr>
</body>
</html>
Q2)
<!DOCTYPE html>
<html lang="en">
<head>
<title>List Q2</title>
</head>
<body>
<h1>Example Lists</h1>
<h2>Ordered List:</h2>
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
<h2>Unordered List:</h2>
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Orange</li>
</ul>
</body>
</html>
Q3) Create an HTML document demonstrating use of images in webpages
(including images
as logos, cell data in a table, background of a table, clickable icons, etc)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Images in Webpages</title>
<style>
table {
background-color: #f2f2f2;
width: 100%;
height: 200px;
border-collapse: collapse;
th, td {
padding: 10px;
.icon {
cursor: pointer;
</style>
</head>
<body>
<header>
</header>
<table>
<tr>
<th>Latest Products</th>
</tr>
<tr>
</tr>
</table>
<div>
</div>
</body>
</html>
Q4)
Create an HTML document to demonstrate Internal and External linking.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Q4</title>
</head>
<body>
<h1>Internal Linking</h1>
<h1>External Linking</h1>
</body>
</html>
Q5)
<html>
<title>Table</title>
<style>
th,td {border:solid; border-color:blue}
th {background-color:yellow;}
</style>
<body>
<table>
<tr color="yellow">
<th colspan="4" >Seminar</th>
</tr>
<tr color="yellow">
<th rowspan="2">Day</th>
<th colspan="2">Schedule</th>
<th rowspan="2">Topic</th>
</tr>
<tr>
<th>Start Time</th>
<th>End Time</th>
</tr>
<tr>
<td rowspan="2">Monday</td>
<td rowspan="2">8:00AM</td>
<td rowspan="2">5:00PM</td>
<td>Introduction to HTML</td>
</tr>
<tr>
<td>Important Html tag</td>
</tr>
<tr bgcolor="grey">
<td rowspan="3">Tuesday</td>
<td>8:00AM</td>
<td>11:00AM</td>
<td rowspan="2">CSS-1</td>
</tr>
<tr bgcolor="grey">
<td>11:00AM</td>
<td>2:00PM</td>
</tr>
<tr bgcolor="grey">
<td>2:00PM</td>
<td>5:00PM</td>
<td>JavaScript-1</td>
</tr>
<tr>
<td>Wednesday</td>
<td>8:00AM</td>
<td>12Noon</td>
<td>JavaScript-2</td>
</tr>
<tr bgcolor="grey">
<td rowspan="2">Thursday</td>
<td>8:00AM</td>
<td>12Noon</td>
<td>JQuery</td>
</tr>
<tr bgcolor="grey">
<td>1:00PM</td>
<td>3:00PM</td>
<td>Valedictory</td>
</tr>
</table>
</body>
</html>
Q6)
<!DOCTYPE html>
<html lang="en">
<head>
<style>
body {
header {
background-color: #333;
color: #fff;
text-align: center;
nav {
background-color: #666;
color: #fff;
text-align: center;
main {
padding: 20px;
margin-bottom: 20px;
padding: 10px;
footer {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
position: fixed;
bottom: 0;
width: 100%;
figure {
margin: 0;
padding: 0;
text-align: center;
figcaption {
font-style: italic;
</style>
</head>
<body>
<header>
<h1>This is a 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>
<section>
<h2>Section 1</h2>
</section>
<article>
<h2>Article 1</h2>
</article>
<details>
<summary>Click to expand</summary>
</details>
<figure>
</figure>
</main>
<footer>
<p>© VANSH.J_CS.COM</p>
</footer>
</body>
</html>
Q7)
. Create a student registration form using HTML which has the following controls:
a. Text Box
b. Text Area
c. Dropdown box
d. Option/radio buttons
e. Check boxes
f. Reset and Submit button
On pressing the Submit button, a message “Form submitted” should be displayed.
<!DOCTYPE html>
<html lang="en">
</head>
<body>
<label for="name">Name:</label><br>
<label for="email">Email:</label><br>
<label for="address">Address:</label><br>
<label for="gender">Gender:</label><br>
<label for="male">Male</label>
<label for="female">Female</label><br><br>
<label for="course">Course:</label><br>
<option value="Medicine">Medicine</option>
<option value="Business">Business</option>
<option value="Arts">Arts</option>
</select><br><br>
<label for="semester">Semester:</label><br>
<label for="skills">Skills:</label><br>
<label for="java">Java</label>
<label for="SQL">SQL</label>
<label for="python">Python</label>
<label for="html">HTML/CSS</label><br><br>
</form>
</body>
</html>
CSS
Q1) Create a webpage for your department with a drop-down navigation menu for faculty,
courses, activities, etc. Implement the webpage using styles, rules, selectors, ID, class.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Department Website</title>
<style>
.dropdown {
position: relative;
display: inline-block;
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
z-index: 1;
.dropdown:hover .dropdown-content {
display: block;
.dropdown-content a {
color: black;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #f1f1f1;
header {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
</style>
</head>
<body>
<header>
<h1>Department of ENGLISH</h1>
</header>
<nav>
<div class="dropdown">
<span>Faculty</span>
<div class="dropdown-content">
<a href="#">Professor A</a>
</div>
</div>
<div class="dropdown">
<span>Courses</span>
<div class="dropdown-content">
</div>
</div>
<div class="dropdown">
<span>Activities</span>
<div class="dropdown-content">
<a href="#">Seminar</a>
<a href="#">Workshop</a>
<a href="#">Conference</a>
</div>
</div>
</nav>
<main>
</main>
<footer>
</footer>
</body>
</html>
Q2) Add appropriate CSS code to change the text, list, div element and table properties of
the HTML questions above
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Department Website</title>
<style>
.dropdown {
position: relative;
display: inline-block;
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
z-index: 1;
.dropdown:hover .dropdown-content {
display: block;
}
/* Styles for links in navigation menu */
.dropdown-content a {
color: black;
text-decoration: none;
display: block;
.dropdown-content a:hover {
background-color: #f1f1f1;
header {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
p{
font-size: 16px;
line-height: 1.6;
ul {
list-style-type: circle;
.container {
width: 80%;
margin: 0 auto;
padding: 20px;
border-radius: 10px;
background-color: #f9f9f9;
table {
width: 100%;
border-collapse: collapse;
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
th {
background-color: #f2f2f2;
</style>
</head>
<body>
<header>
<h1>Department of ENG</h1>
</header>
<nav>
<div class="dropdown">
<span>Faculty</span>
<div class="dropdown-content">
</div>
</div>
<div class="dropdown">
<span>Courses</span>
<div class="dropdown-content">
</div>
</div>
<div class="dropdown">
<span>Activities</span>
<div class="dropdown-content">
<a href="#">Seminar</a>
<a href="#">Workshop</a>
<a href="#">Conference</a>
</div>
</div>
</nav>
<main>
<div class="container">
<ul>
<li>List item 1</li>
</ul>
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
</div>
</main>
<footer>
</footer>
</body>
</html>
Java SCRIPT
Q1)
Write a Javascript code to accept a number from the user through the prompt and print its
multiplication table.
<html>
<head>
<title>Multiplication Table</title>
</head>
<body>
<h2>Multiplication Table</h2>
<script>
function displayMultiplicationTable() {
var num = prompt("Enter a number:");
if (num !== null && !isNaN(num)) {
num = parseInt(num);
var table = "<h3>Multiplication Table for " + num + ":</h3>";
for (var i = 1; i <= 10; i++) {
var result = num * i;
table += num + " x " + i + " = " + result + "<br>";
}
document.body.innerHTML += table;
} else {
alert("Invalid input! Please enter a valid number.");
}
}
<script>
function addition() {
var num1 = parseFloat(document.getElementById("num1").value);
var num2 = parseFloat(document.getElementById("num2").value);
var result = num1 + num2;
alert("Result: " + result);
}
function subtraction() {
var num1 = parseFloat(document.getElementById("num1").value);
var num2 = parseFloat(document.getElementById("num2").value);
var result = num1 - num2;
alert("Result: " + result);
}
function multiplication() {
var num1 = parseFloat(document.getElementById("num1").value);
var num2 = parseFloat(document.getElementById("num2").value);
var result = num1 * num2;
alert("Result: " + result);
}
function division() {
var num1 = parseFloat(document.getElementById("num1").value);
var num2 = parseFloat(document.getElementById("num2").value);
if (num2 === 0) {
alert("Cannot divide by zero!");
} else {
var result = num1 / num2;
alert("Result: " + result);
}
}
</script>
</body>
</html>
3. Write a Javascript code to change the background color of a text box when the text
box gets focus.
<html>
<head>
<title>Change Text-box Background</title>
</head>
<body style="background-color: skyblue;">
<h2>Change Text-box Background Color</h2>
<form id="calculatorForm">
<label for="num1">Number 1:</label>
<input type="text" id="num1" name="num1"
onfocus="changeBackgroundColor(this)"><br><br>
<script>
function changeBackgroundColor(element) {
element.style.backgroundColor = "#00ffff";
}
function addition() {
var num1 = parseFloat(document.getElementById("num1").value);
var num2 = parseFloat(document.getElementById("num2").value);
var result = num1 + num2;
alert("Result: " + result);
}
function subtraction() {
var num1 = parseFloat(document.getElementById("num1").value);
var num2 = parseFloat(document.getElementById("num2").value);
var result = num1 - num2;
alert("Result: " + result);
}
function multiplication() {
var num1 = parseFloat(document.getElementById("num1").value);
var num2 = parseFloat(document.getElementById("num2").value);
var result = num1 * num2;
alert("Result: " + result);
}
function division() {
var num1 = parseFloat(document.getElementById("num1").value);
var num2 = parseFloat(document.getElementById("num2").value);
if (num2 === 0) {
alert("Cannot divide by zero!");
} else {
var result = num1 / num2;
alert("Result: " + result);
}
}
</script>
</body>
</html>
4. Write a Javascript code for Q7 (of HTML above) to input and validate all data. Create
functions to perform validation of each element, for example:
a. Roll number is a 7-digit numeric value.
b. Name should be an alphabetical value (String).
c. Non-empty fields like DOB.
<html >
<head>
<title>Registration Form</title>
</head>
<body style="background-color: teal;">
<h1 style="color: #FC6A03; text-align: center;">Registration Form</h1>
<h2 style="text-align: center;">A Student Registration Form</h2>
<form id="form" autocomplete="on">
<fieldset>
<label for="fname">First Name:</label><br>
<input type="text" id="fname" name="fname" autofocus required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" minlength="5"
maxlength="15" required><br><br>
<label for="address">Address:</label><br>
<textarea id="address" name="address" required></textarea><br><br>
<label for="gender">Gender:</label><br>
<input type="radio" id="male" name="gender" value="Male">
<label for="male">Male</label><br>
<input type="radio" id="female" name="gender" value="Female">
<label for="female">Female</label><br><br>
<label>Courses:</label><br>
<input type="checkbox" id="course1" name="course1" value="DSC">
<label for="course1"> Do you have select your discipline courses?</label><br>
<input type="checkbox" id="course2" name="course2" value="GE">
<label for="course2"> Do you know GE Courses</label><br>
<input type="checkbox" id="course3" name="course3" value="SEC">
<label for="course3"> Do you know SEC Courses</label><br>
<input type="checkbox" id="course4" name="course4" value="VAC">
<label for="course4"> Do you know SEC Courses</label><br><br>
<script>
function validateForm() {
var fname = document.getElementById("fname").value.trim();
var lname = document.getElementById("lname").value.trim();
var rollno = document.getElementById("rollno").value.trim();
var phone = document.getElementById("phone").value.trim();
var password = document.getElementById("password").value.trim();
var address = document.getElementById("address").value.trim();
if (fname === "" || lname === "" || rollno === "" || phone === "" || password ===
"" || address === "") {
alert("Please fill in all fields.");
return;
}
if (!/^[a-zA-Z]+$/.test(fname) || !/^[a-zA-Z]+$/.test(lname)) {
alert("First name and last name should contain only alphabets.");
return;
}
if (!/^\d{7}$/.test(rollno)) {
alert("Roll number should be a 7-digit numeric value.");
return;
}
if (!/^\d{10}$/.test(phone)) {
alert("Phone number should be a 10-digit numeric value.");
return;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#changeColor").click(function(){
$(".text").css("color", "red");
});
$("#changeText").click(function(){
$(".text").text("New text content");
});
});
</script>
</body>
</html>
2. Select elements using ID, class, elements name, attribute name.
<html>
<head>
<title>jQuery Selectors</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
.highlight {
background-color: pink;
}
</style>
</head>
<body>
<h1 id="heading">Hello, jQuery!</h1>
<button id="btn1">Click me!</button>
<div class="container">
<p>This is a paragraph inside a container.</p>
</div>
<input type="text" name="username" placeholder="Enter your username" data-
type="inputField">
<script>
// Select elements by ID, class, element name, and attribute name
// Select by ID
$("#heading").text("Welcome to jQuery!");
$(document).ready(function() {
$('#checkDateBtn').click(function() {
var inputDate = $('#dateInput').val();
if (isWeekend(inputDate)) {
$('#result').text(inputDate + ' is a weekend.');
} else {
$('#result').text(inputDate + ' is not a weekend.');
}
});
});
</script>
</head>
<body>
<label for="dateInput">Enter a Date:</label>
<input type="text" id="dateInput" placeholder="YYYY-MM-DD">
<button id="checkDateBtn">Check</button>
<p id="result"></p>
</body>
</html>
4. Demonstrate various events: blur, change, focus, click, dblClick, submit.
<html>
<head>
<title>jQuery Events</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$('#inputBlur').blur(function() {
$('#outputBlur').text('Input blurred');
});
$('#inputChange').change(function() {
$('#outputChange').text('Value changed to: ' + $(this).val());
});
$('#inputFocus').focus(function() {
$('#outputFocus').text('Input focused');
});
$('#btnClick').click(function() {
$('#outputClick').text('Button clicked');
});
$('#btnDoubleClick').dblclick(function() {
$('#outputDoubleClick').text('Button double-clicked');
});
$('#formSubmit').submit(function(event) {
event.preventDefault(); // Prevent form submission
$('#outputSubmit').text('Form submitted');
});
});
</script>
</head>
<body>
<label for="inputBlur">Blur Event:</label>
<input type="text" id="inputBlur">
<p id="outputBlur"></p>
<form id="formSubmit">
<label for="textInput">Submit Event:</label>
<input type="text" id="textInput">
<input type="submit" value="Submit">
</form>
<p id="outputSubmit"></p>
</body>
</html>
5. Write a jQuery code that demonstrates the mouseOver and mouseOut event.
a. The web page should have a hyperlink labeled “It shows the mouse events” and
linked to your college website.
b. When the mouse hovers over the link, the background color of webpage should
change to green and link text should change to “I’m green now”.
c. When the mouse is taken away from the link, the background color of webpage
should change to red and the link text should change to “I’m red now”.
<!DOCTYPE html>
<html>
<head>
<title>Mouse Events Demo</title>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jque
ry.min.js"></script>
<style>body{transition:background-color 0.5s ease;
}
</style>
</head>
<script>
$(document).ready(function(){
$("#mouseLink").mouseover(function(){
$("body").css("background-color", "green");
$(this).text("I'm green now");
});
$("#mouseLink").mouseout(function(){
$("body").css("background-color", "red");
$(this).text("I'm red now");
});
});
</script>
</head>
<body>
ABC
</body>
</html>