short type wt
short type wt
UNIT-I
The World Wide Web (WWW) is an information space where documents and other web
resources are identified by URLs (Uniform Resource Locators), interlinked by hypertext links,1
and accessible via the Internet. It's the foundation for how we access and interact with
information online, using browsers to view web pages, images, videos, and more. Essentially,
it's a vast network of interconnected content.
Tag Closing Optional for some tags Mandatory for all tags
(e.g., <p>). (e.g., <p></p>).
Example:
HTML
<p>This is a paragraph.<br> ```
**XHTML (Stricter):**
```xhtml
<p>This is a paragraph.</p>
<br /> ```
**(iii) How is the DOM model useful?**
The Document Object Model (DOM) is a platform and language-neutral
convention for representing and interacting with objects in HTML,
XHTML, and XML documents. It's crucial because it:
1. **Allows Dynamic Updates:** The DOM represents the structure of a
document as a tree of nodes, which can be manipulated using scripting
languages like JavaScript. This enables dynamic updates to content,
style, and structure without reloading the page.
**Example:** Changing the text of a paragraph using JavaScript:
```javascript
document.getElementById("myParagraph").innerHTML = "New Text!";
2. Enables Interactivity: The DOM allows scripts to access and modify any element in the
document, making interactive features like form validation, animations, and user interface
changes possible.
3. Supports Accessibility: Screen readers and other assistive technologies use the DOM to
interpret web page content for users with disabilities.
4. Facilitates Web Development Tools: Browser developer tools use the DOM to inspect
and debug web pages. Search engines also use the DOM to crawl and index web page
content.
UNIT-II
(i) What is Cascading Style Sheet (CSS)? Explain different types of style sheets in CSS.
Cascading Style Sheets (CSS) is a style sheet language used to describe the presentation of a
document written in a markup language2 like HTML. It controls the colors, fonts, layout, and
other visual aspects of a website.
○ Advantages: Best for maintainability, reusable styles across multiple pages, improves
website performance (caching).
○ Disadvantages: Requires an extra HTTP request to load the CSS file.
CSS selectors are patterns used to select the HTML elements you want to style.
1. Element Selectors (Type Selectors): Select elements based on their tag name.
Example:
CSS
p { color: purple; } /* Selects all <p> elements */
4. Attribute Selectors: Select elements based on the presence or value of an attribute.
Examples:
CSS
a[href] { color: blue; } /* Selects all <a> elements with an href
attribute */
input[type="text"] { border: 1px solid gray; } /* Selects text
input fields */
6. Pseudo-classes: Select elements based on their state (e.g., hover, active).
Examples:
CSS
a:hover { color: red; } /* Styles a link when the mouse hovers over
it */
button:active { background-color: lightgray; } /* Styles a button
when it's clicked */
7. Pseudo-elements: Style specific parts of an element (e.g., first letter, before/after content).
Examples:
CSS
p::first-letter { font-size: 1.5em; } /* Styles the first letter of
a paragraph */
::before { content: ""; } /* Insert generated content before an
element */
○ Adjacent Sibling Selector (+): Selects the element immediately following another
element.
CSS
h2 + p { font-style: italic; } /* Selects the <p> element
immediately after an <h2> */
○ General Sibling Selector (~): Selects sibling elements that follow another element.
CSS
h2 ~ p { text-decoration: underline; } /* Selects all <p>
elements that are siblings of <h2> */
(iii) Write a JavaScript program embedded into an HTML page to display whether a given
number is a prime or not.
HTML
<!DOCTYPE html>
<html>
<head>
<title>Prime Number Checker</title>
</head>
<body>
<h1>Check if a Number is Prime</h1>
<input type="number" id="numberInput">
<button onclick="checkPrime()">Check</button>
<p id="result"></p>
<script>
function checkPrime() {
let num = document.getElementById("numberInput").value;
let isPrime = true;
if (num <= 1) {
isPrime = false;
} else {
for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i === 0) {
isPrime = false;
break;
}
}
}
let resultElement = document.getElementById("result");
if (isPrime) {
resultElement.textContent = num + " is a prime number.";
} else {
resultElement.textContent = num + " is not a prime number.";
}
}
</script>
</body>
</html>
Explanation:
1. HTML Structure:
○ An input field (<input type="number">) allows the
Sources
1.
https://patentimages.storage.googleapis.com/1f/74/0b/3afdeb47a893ce/US20180091627A1.pdf
2. https://www.scribd.com/document/511100540/Hotel-Reservation-System-Final-THESIS