Practice Set Web 70
Practice Set Web 70
Practice Set Web 70
1 Working of web
We will have a client on the left side and server on the right side. A user wants
to see a website, like www.javatpoint.com/java-tutorial. The user types the
URL of a page using a client program, usually a browser. But first, the
computer of the user and the web server need to be physically connected.
That is the job of the internet. Using the TCP/IP protocol, it establishes a
connection using a combination of cable media or wireless media and does all
the necessary work to prepare the environment for the two computers to talk
via the HTTP protocol.
When the connection establishes, the client sends a request called the HTTP
message, but because the HTTP is a connectionless protocol, so the client
disconnects from the server and waits for the response.
On the other side, the server processes the request, prepare the response,
establish the connection again, and send it back the response and again in
the form of an HTTP message to the client. Then the two computers
completely disconnect.
SMTP
ProtocolSMTP stands for Simple Mail Transfer Protocol. SMTP is the
principal email protocol that is responsible for the transfer of emails between
email clients and email servers.
Internet protocols - set of rules hote hai that governs the communication and
exchange of data over the internet. Both the sender and receiver should follow
the same protocols in order to communicate the data.
Types of protocols
5 Examples of Internet browsers
The most popular web browsers are Google Chrome, Microsoft Edge
(formerly Internet Explorer), Mozilla Firefox, and Apple's Safari. If you
have a Windows computer, Microsoft Edge (or its older counterpart, Internet
Explorer) are already installed on your computer.
6 Explain Dial-Up Connectivity to start Internet.
When you connect to the internet using dial-up, your computer uses a modem
to convert digital data from your computer into analog signals that can be
transmitted over a telephone line. These analog signals are then sent to the
internet service provider’s (ISP's) equipment, which converts them back into
digital data and connects you to the internet.
No, you cannot use dial-up and broadband simultaneously on the same line.
Dial-up requires exclusive access to the telephone line, so if you want to
switch to broadband, you will need to disconnect your dial-up connection.
Browsers are responsible for retrieving and displaying web content to users.
When a user enters a URL or clicks on a link, the browser initiates a complex
series of actions to retrieve the web content from a server and display it on the
user’s device.
The process begins with Domain Name System (DNS) resolution, where the
browser translates the domain name into an IP address to locate the server
where the web page is stored.
The browser then sends an HTTP request to the server, specifying the
path and parameters of the requested resource.
Once the server receives the request, it sends an HTTP response to the
browser containing the requested resource in HTML, CSS, and
JavaScript code.
The browser’s rendering engine interprets and renders the code to
display the web page on the user’s device.
The CSS stylesheets are applied to format the web page’s content,
including fonts, colors, and layout.
The browser may also execute JavaScript code on the web page to add
interactivity and dynamic behavior.
As new content is loaded or changes are made to the web page, the browser
updates the display accordingly.
Stateless Protocols are the type of network protocols in which Client send
request to the server and server response back according to current state. It
does not require the server to retain session information or a status about
each communicating partner for multiple request.
HTTPS establishes the communication between the browser and the web
server. It uses the **Secure Socket Layer** (SSL) and **Transport Layer
Security** (TLS) protocol for establishing communication. The new version of
SSL is **TLS(Transport Layer Security)**.
11 What is the purpose of tag in HTML What are different tags
used in tag? Explain with the help of a suitable example.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
<script src="script.js" defer></script>
</head>
<body>
</body>
</html>
Here are some of the commonly used tags within the <head> tag:
1. <title>: Defines the title of the document, which appears in
the browser's title bar or tab.
2. <meta>: Provides metadata about the HTML document, such as
character set, author, description, and keywords for search
engines.
3. <link>: Specifies external resources like stylesheets (CSS)
or icons.
4. <style>: Defines internal CSS styles for the document.
5. <script>: Includes JavaScript code or links to external
JavaScript files.
1. Inline CSS: You can add CSS directly to HTML elements using the style
attribute.
2. Internal CSS: CSS can be included within the HTML document using the
style tag in the head section.
3. External CSS: CSS can be written in an external file and linked to the
HTML document using the link tag.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>CSS Examples</title>
</head>
<body>
</body>
</html>
13 How can we add image in a web page? Write the names of four
attributes used for image show.
<img
src="images/dinosaur.jpg"
alt="The head and torso of a dinosaur skeleton;
it has a large head with long sharp teeth"
width="400"
height="341"
title="A T-Rex on display in the Manchester University Museum"
/>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Text and Image Animation</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<div class="text">This text moves from bottom to
top</div>
<img src="example.jpg" alt="Example Image"
class="image">
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Text and Image Animation</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<div class="text">This text moves from bottom to
top</div>
<img src="example.jpg" alt="Example Image"
class="image">
</div>
</body>
</html>
https://www.scaler.com/topics/difference-between-html-and-xhtml/
19 Create a web page using links, list, div, images and videos.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Web Page Example</title>
</head>
<body>
<header>
<h1>Web Page Example</h1>
</header>
<nav>
<a href="#section1">Section 1</a>
<a href="#section2">Section 2</a>
<a href="#section3">Section 3</a>
</nav>
<section id="section1">
<h2>Section 1</h2>
<div class="container">
<div class="box">
<h3>List Example</h3>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</div>
<div class="box">
<h3>Image Example</h3>
<img src="image.jpg" alt="Image">
</div>
<div class="box">
<h3>Link Example</h3>
<a href="https://www.example.com">Visit
Example</a>
</div>
</div>
</section>
<section id="section2">
<h2>Section 2</h2>
<div class="container">
<div class="box">
<h3>Div Example</h3>
<div>This is a div element.</div>
</div>
<div class="box">
<h3>Image Example</h3>
<img src="image2.jpg" alt="Image">
</div>
<div class="box">
<h3>Video Example</h3>
<iframe
src="https://www.youtube.com/embed/dQw4w9WgXcQ" allowfullscreen>
</iframe>
</div>
</div>
</section>
<section id="section3">
<h2>Section 3</h2>
<div class="container">
<div class="box">
<h3>List Example</h3>
<ul>
<li>Item A</li>
<li>Item B</li>
<li>Item C</li>
</ul>
</div>
<div class="box">
<h3>Image Example</h3>
<img src="image3.jpg" alt="Image">
</div>
<div class="box">
<h3>Link Example</h3>
<a href="https://www.example.com">Visit
Example</a>
</div>
</div>
</section>
</body>
</html>
20 write an XML file which will display the Book information which
includes the following: Title of the book, Author Name, ISBN
number, Publisher name, Edition and Price. Validate the above
document using DTD and XML Schema.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library SYSTEM "library.dtd">
<library>
<book>
<title>The Great Gatsby</title>
<author>F. Scott Fitzgerald</author>
<isbn>978-3-16-148410-0</isbn>
<publisher>Charles Scribner's Sons</publisher>
<edition>First</edition>
<price>10.99</price>
</book>
<book>
<title>To Kill a Mockingbird</title>
<author>Harper Lee</author>
<isbn>978-3-16-148410-1</isbn>
<publisher>J. B. Lippincott & Co.</publisher>
<edition>Reprint</edition>
<price>12.99</price>
</book>
</library>
21 Create two links using HTML in which first link will connect to
another page the second linl to heading in the same page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Links Example</title>
</head>
<body>
<h1>Welcome to My Website</h1>
</body>
</html>
unordered list
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
ordered list
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
defination list
<dl>
<dt>Coffee</dt>
<dd>Black hot drink</dd>
<dt>Milk</dt>
<dd>White cold drink</dd>
</dl>
nested list
<ul>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
`<``website``>`
`<``company` `category``=``"geeksforgeeks"``>`
`<``title``>Machine learning</``title``>`
`<``author``>aarti majumdar</``author``>`
`<``year``>2022</``year``>`
`</``company``>`
`<``company` `category``=``"geeksforgeeks"``>`
`<``title``>Web Development</``title``>`
`<``author``>aarti majumdar</``author``>`
`<``year``>2022</``year``>`
`</``company``>`
`<``company` `category``=``"geeksforgeekse"``>`
`<``title``>XML</``title``>`
`<``author``>aarti majumdar</``author``>`
`<``year``>2022</``year``>`
`</``company``>`
`</``website``>`
Structure -
`<``company``>geeksforgeeks</``company``>`
`</``website``>`
25
kr chuke hai
30 Create a web page in which using div tag, CSS classes and
CSS box properties.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Div Tag Example</title>
<style>
/* CSS for styling */
.container {
width: 80%;
margin: 0 auto;
padding: 20px;
background-color: #f0f0f0;
border: 2px solid #ccc;
border-radius: 10px;
}
.header {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
}
.content {
margin-top: 20px;
padding: 10px;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 5px;
}
.footer {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
margin-top: 20px;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>Welcome to My Website</h1>
</div>
<div class="content">
<p>This is the content of my web page. It is
contained within a div with the class "content".</p>
<p>Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Nullam suscipit leo sit amet sapien facilisis,
vitae consequat ipsum placerat. Nam vel risus in metus tincidunt
rutrum. Suspendisse potenti. Nunc id velit in urna venenatis
consequat vel sed nisi. Nulla facilisi. Sed at dolor non orci
tristique dapibus.</p>
</div>
<div class="footer">
<p>© 2024 My Website. All rights reserved.</p>
</div>
</div>
</body>
</html>
1. Alert box
2. Confirm box
confirm("Press")
3. Prompt
function validateEmail(email) {
if(!document.getElementById(email-field).value.match(/^[A-
Za-z\.0-9]*[@][A-Za-z]*[\.][a-z]{2,4}$/))
return true;
}
return false;
<script>
function validateForm() {
var name = document.getElementById("name").value;
var email = document.getElementById("email").value;
var nameError =
document.getElementById("nameError");
var emailError =
document.getElementById("emailError");
var isValid = true;
// Validate name
if (name.trim() === "") {
nameError.textContent = "Name is required";
isValid = false;
} else {
nameError.textContent = "";
}
// Validate email
if (email.trim() === "") {
emailError.textContent = "Email is required";
isValid = false;
} else {
emailError.textContent = "";
}
return isValid;
}
< script>
< body>
< html>
36 Multiple slects
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Dropdown List Example</title>
</head>
<body>
<form>
<label for="fruits">Choose a fruit:</label>
<select id="fruits" name="fruits" multiple>
<option value="apple">Apple</option>
<option value="banana">Banana</option>
<option value="orange">Orange</option>
<option value="strawberry">Strawberry</option>
<option value="grape">Grape</option>
</select>
</form>
</body>
</html>
37 Write a java script program which shows history and other
DOM objects.
` <``strong``>`
`</``strong``>`
`<``input` `type``=``"button"`
`value``=``"Back"`
`onclick``=``"previousPage()"``>`
`<``script``>`
`function previousPage() {`
`window.history.back();`
`}`
`</``script``>`
function buttonClickHnadler(){
console.log("clicked");
xhr.onload = function(){
console.log("loded");
xhr.send();
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Addition Using Prompt Box< title>
< head>
<body>
<script>
// Prompt the user to enter the first number
var num1 = prompt("Enter the first number:");
< body>
< html>
The JSON format is syntactically similar to the code for creating JavaScript
objects. Because of this, a JavaScript program can easily convert JSON data
into JavaScript objects.
Since the format is text only, JSON data can easily be sent between
computers, and used by any programming language.
JavaScript has a built in function for converting JSON strings into JavaScript
objects:
JSON.parse()
JavaScript also has a built in function for converting an object into a JSON
string:
JSON.stringify()
'{"name":"John", "age":30, "car":null}'
42 jQuery
jQuery takes a lot of common tasks that require many lines of JavaScript code
to accomplish, and wraps them into methods that you can call with a single
line of code.
console.log("using jQuery");
$('selector').action() //Syntax
$('p').click(()=>{"clicked on p"})
$ is sign of jquery
47 Create a web page which divides the page in two equal frames
and place the audio and video clips in frame-1 and frame-2
respectively. Execution will be on the basis of user input: (Sad /
Happy).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Audio and Video Player< title>
<style>
body, html {
height: 100%;
margin: 0;
overflow: hidden;
}
#container {
display: flex;
height: 100%;
}
#frame1, #frame2 {
flex: 1;
overflow: auto;
border: 1px solid #ccc;
}
#frame1 audio, #frame2 video {
width: 100%;
height: auto;
}
< style>
< head>
<body>
<div id="container">
<div id="frame1">
<audio controls id="audioPlayer">
<source src="" type="audio/mpeg">
Your browser does not support the audio element.
< audio>
< div>
<div id="frame2">
<video controls id="videoPlayer">
<source src="" type="video/mp4">
Your browser does not support the video element.
< video>
< div>
< div>
<script>
function loadMedia(mood) {
var audioPlayer =
document.getElementById("audioPlayer");
var videoPlayer =
document.getElementById("videoPlayer");
< body>
< html>
48 Calcultaor
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Calculator< title>
<style>
.calculator {
width: 200px;
margin: 0 auto;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #f9f9f9;
}
input[type="text"] {
width: 100%;
margin-bottom: 5px;
padding: 5px;
font-size: 16px;
border-radius: 3px;
border: 1px solid #ccc;
}
input[type="button"] {
width: 48%;
padding: 10px;
font-size: 16px;
border-radius: 3px;
border: 1px solid #ccc;
cursor: pointer;
margin-bottom: 5px;
}
< style>
< head>
<body>
<div class="calculator">
<input type="text" id="result" disabled>
<input type="button" value="7"
onclick="appendToResult('7')">
<input type="button" value="8"
onclick="appendToResult('8')">
<input type="button" value="9"
onclick="appendToResult('9')">
<input type="button" value="+"
onclick="appendToResult('+')">
<input type="button" value="4"
onclick="appendToResult('4')">
<input type="button" value="5"
onclick="appendToResult('5')">
<input type="button" value="6"
onclick="appendToResult('6')">
<input type="button" value="-"
onclick="appendToResult('-')">
<input type="button" value="1"
onclick="appendToResult('1')">
<input type="button" value="2"
onclick="appendToResult('2')">
<input type="button" value="3"
onclick="appendToResult('3')">
<input type="button" value="*"
onclick="appendToResult('*')">
<input type="button" value="C" onclick="clearResult()">
<input type="button" value="0"
onclick="appendToResult('0')">
<input type="button" value="=" onclick="calculate()">
<input type="button" value="/"
onclick="appendToResult('/')">
< div>
<script>
function appendToResult(value) {
document.getElementById("result").value += value;
}
function clearResult() {
document.getElementById("result").value = "";
}
function calculate() {
var result =
eval(document.getElementById("result").value);
document.getElementById("result").value = result;
}
< script>
< body>
< html>
49 Write a JavaScript program to input name and address of a
visitor and display a greeting message.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Greeting Message< title>
< head>
<body>
<script>
// Prompt the user to input name and address
var name = prompt("Enter your name:");
var address = prompt("Enter your address:");
< body>
< html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>AJAX Example< title>
< head>
<body>
<script>
function printTable() {
var number =
document.getElementById("number").value;
var table = document.getElementById("table");
< body>
< html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>String and Math Functions< title>
< head>
<body>
// Concatenation
var concatStr = str1.concat(" ", str2);
console.log("Concatenated string:", concatStr);
// Uppercase
console.log("Uppercase:", str1.toUpperCase());
// Lowercase
console.log("Lowercase:", str2.toLowerCase());
// Substring
console.log("Substring:", sentence.substring(10, 15));
// IndexOf
console.log("Index of 'quick':",
sentence.indexOf("quick"));
// Replace
console.log("Replace 'fox' with 'cat':",
sentence.replace("fox", "cat"));
< script>
// Math operations
var num1 = 10;
var num2 = 5;
// Math functions
console.log("Square root of 16:", Math.sqrt(16));
console.log("Absolute value of -5:", Math.abs(-5));
console.log("Ceiling of 3.7:", Math.ceil(3.7));
console.log("Floor of 3.7:", Math.floor(3.7));
console.log("Random number between 0 and 1:",
Math.random());
< script>
< body>
< html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Bootstrap Example< title>
<link
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/boo
tstrap.min.css" rel="stylesheet">
< head>
<body>
<div class="container">
<h1>Hello, Bootstrap!< h1>
<button class="btn btn-primary">Click Me< button>
< div>
<script
src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/boots
trap.min.js">< script>
< body>
< html>