Web Applications Assigment
Web Applications Assigment
Ans:
XHTML:
● XHTML is easy to use with other data formats, and it creates more neat code
as it is stricter than HTML. Therefore, it is more compatible with most
browsers, and it maintains a standard of code that can be used for various
devices.
<head>
<title>Sample XHTML Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />
</head>
<body>
<h1>Hello World</h1>
<p>This is a sample XHTML document.</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</body>
</html>
The XHTML document in the above example begins with the declaration of the
document type (DOCTYPE) and the <html> element, which identifies the XHTML
namespace. The <head> element contains document-specific information like as the
title and character encoding. The <body> element contains the main content of the
document, including a heading, a paragraph, and an unordered list.
It's important to note that in XHTML, all elements must be properly nested and all
attributes must be quoted. This strict syntax is one of the key differences between
XHTML and HTML.
XHTML:
● Hypertext Mark-up Language (HTML) is a programming language that
shows information and depicts a site page's design.
● HTML is a programming language used to make sites that anybody with web
access can see. The labels are the words between the < angle brackets > and
separate standard content from HTML code. These are shown on website
pages as pictures, tables, outlines, etc.
The <!DOCTYPE html> declaration defines the document type and version of HTML
used in the document.
The <html> element is the root element of the HTML document, and all the other
elements are nested inside it.
12. Search engine XHTML can provide better HTML may not provide as
optimization SEO, as the strict syntax good SEO, as the relaxed
(SEO) and semantic meaning syntax and semantic
make it easier for search meaning can lead to less
engines to understand and predictable results and
rank the content. make it harder for search
engines to understand and
rank the content.
15. File Saving .xhtml, .xml, and .xht are .html and .htm are the
the file extensions used by extensions used by HTML
XHTML
It should be noted that these are broad comparisons, and the exact benefits and
downsides of XHTML and HTML will vary depending on the individual use case and
needs.
Ans:
a)
Data type:
A data type is a classification that dictates what a variable or object can hold in
computer programming. Data types are essential in almost all computer
programming languages, including C#, C++, JavaScript, and Visual Basic.
● Primitive data types in javascript are those that are specified at the most
fundamental level of the language.
● These Javascript data types cannot be further destructured, and they lack any
pre-defined properties or functions. They are only used to keep objects of the
same type.
➢ Numbers: It is used for numeric values and can be written with or without
➢ BigInt: It is used for storing integer values larger than the maximum safe
integer value in JavaScript. It has the ability to work with large numbers
➢ String: It is used for storing text and is written in single or double quotes.
➢ Boolean: It is used for storing either true or false values. It performs logical
operations quickly.
➢ Undefined: It is used to denote that a variable has not been assigned a value.
Advantages include the ability to quickly identify variables that have not
➢ Null: It is used for explicitly assigning a null value to a variable. But it should
includes the need to convert Symbols to strings before they can be used.
2. Non-primitive Javascript Data Types:
There are mainly three types of non-primitive (or complex) data types in javascript:
while disadvantages include the need to parse through the structure to find
specific data.
Example:
let obj = {
key: "value"
}
➢ Array: It is a special type of data type that can store multiple values in a
single variable.
Advantages include the ability to quickly access and manipulate data, while
array.
Example:
certain pattern.
Example:
//Declaring regExp
let pattern1 = /HelloWorld/e;
//declaring constructor
let pattern2 = new RegExp('/HelloWorld/e');
b)
JavaScript function to find the factorial of a number:
function factorial(n) {
let result = 1;
for (let i = 1; i <= n; i++) {
result = result * i;
}
return result;
}
● The function ‘factorial’ takes a single argument ‘n’, which represents the
number for which we want to find the factorial.
● Within the function body, we declare a variable ‘result’ and set it to ‘1’. This
variable will hold the factorial computation result.
● Next, we have a ‘for’ loop that iterates ‘n’ times. In each iteration, we multiply
the ‘result’ by the loop counter ‘i’, which starts at ‘1’ and increments by ‘1’ in
each iteration, until it reaches ‘n’. This loop calculates the factorial of ‘n’ by
multiplying all the integers from ‘1’ to ‘n’.
let num = 5;
let factorialOfNum = factorial(num);
console.log(factorialOfNum);
This code will output the value ‘120’, which is the factorial of ‘5’.
Q. What is a form? What are the significant attributes of the form? Explain
any six form components with examples.
Ans:
Form tag:
● An HTML form is an element used to gather data from the user and send it to
a server for processing.
● Forms are an essential part of many websites, as they allow users to interact
with the website by filling out the information, making selections, and
submitting requests.
● The <form> tag defines an HTML form, which can contain text fields,
checkboxes, radio buttons, and other form elements.
● The form elements are used to accept user input and are enclosed within the
opening and closing <form> tags.
Example:
<form>
<input type="text" name="name">
<input type="email" name="email">
<input type="submit" value="Submit">
</form>
There are various attributes that can be used with the form tag in HTML. Some of
the significant attributes of the form tag are:
1. ‘action’: Specifies the URL where the form data will be sent when the form
is submitted. The value of this attribute should be the URL of the server-side
script that will process the form data.
Syntax:
<form action="https://example.com/submit-form">
<!-- form content goes here -->
</form>
2. ‘method’: Specifies the ‘HTTP’ method that will be used to submit the form
data. The two most common methods are ‘GET’ and ‘POST’. ‘GET’ is used to
retrieve information from the server, while ‘POST’ is used to send data to the
server.
3.
Syntax:
<form action="https://example.com/submit-form" method="post">
<!-- form content goes here -->
</form>
4. ‘target’: Specifies where the response from the server will be displayed. For
example, you can use ‘_blank’ to open the response in a new window, or
‘_self’ to display the response in the same window as the form.
Syntax:
<form action="https://example.com/submit-form" method="post"
target="_blank">
<!-- form content goes here -->
</form>
5. ‘enctype’: Specifies the encoding type used to encode the form data before it
is sent to the server. The most commonly used encoding type is
‘/x-www-form-urlencoded’.
Syntax:
<form action="https://example.com/submit-form" method="post"
enctype="/x-www-form-urlencoded">
<!-- form content goes here -->
</form>
6. ‘autocomplete’: Specifies whether the browser should automatically fill in
form values based on previous submissions. The default value is ‘on’, but you
can set it to ‘off’ if you don't want the browser to remember form values.
Syntax:
<form action="https://example.com/submit-form" method="post"
autocomplete="off">
<!-- form content goes here -->
</form>
Syntax:
<form action="https://example.com/submit-form" method="post"
novalidate>
<!-- form content goes here -->
</form>
Form components:
Some of the most important components are:
1. <input>: A basic form element used to accept data from the user. The type
attribute of the input element determines the type of input it accepts, such as
text, email, password, checkbox, radio button, and more.
Example:
<form>
<input type="text" name="name”>
</form>
2. <textarea>: A multi-line text input field for accepting larger amounts of text.
Example:
<form>
<label for="message">Message:</label>
<textarea id="message" name="message"></textarea>
</form>
3. <select>: A drop-down list for selecting one or more options from a list of
choices.
Example:
<form>
<label for="country">Country:</label>
<select id="country" name="country">
<option value="">Select a country</option>
<option value="USA">USA</option>
</select>
</form>
Example:
<form>
<label for="country">Country:</label>
<select id="country" name="country">
<option value="">Select a country</option>
<option value="USA">USA</option>
<option value="Canada">Canada</option>
<option value="Mexico">Mexico</option>
</select>
</form>
Example:
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username">
</form>
6. <button>: A button for submitting the form or triggering some other action.
Example:
<form>
<button type="submit">Submit</button>
</form>
Example:
<form>
<fieldset>
<legend>Personal Information</legend>
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email">
</fieldset>
</form>
Example:
<form>
<fieldset>
<legend>Personal Information</legend>
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email">
</fieldset>
</form>
9. <datalist>: A list of options that can be used with the <input> element to
provide a drop-down list of suggestions to the user.
Example:
<form>
<label for="browser">Browser:</label>
<input type="text" id="browser" name="browser"
list="browsers">
<datalist id="browsers">
<option value="Chrome">
<option value="Firefox">
<option value="Safari">
<option value="Edge">
<option value="Internet Explorer">
</datalist>
</form>
Submitted by
Nare Mokshagna