MST_MID_-1[1]
MST_MID_-1[1]
UNIT - 1
<header>
<h1>Welcome to My Website</h1>
</header>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
<section>
<article>
<h2>About HTML5</h2>
<p>HTML5 is the latest version of HTML and includes new features for better web
development.</p>
</article>
</section>
<footer>
<p>© 2024 My Website</p>
</footer>
</body>
</html>
Key Differences Between HTML and HTML5
• DOCTYPE: Simplified in HTML5 (<!DOCTYPE html>).
• Semantic Elements: New elements like <header>, <footer>, <section>, etc., which
improve document structure and readability.
• Multimedia: Native support for audio and video without external plugins (e.g.,
Flash).
• APIs: HTML5 includes APIs for features like geolocation, local storage, and offline
applications.
• Form Input: HTML5 has better input controls like email, date, number, etc.
This basic structure and the new features introduced in HTML5 have made it a more
powerful and developer-friendly language for creating modern web applications.
=====================================================================
2. Discuss different types of HTML Elements
1. Block-Level Elements
• Definition: Block-level elements occupy the full width of their parent container (like
the browser window or a <div>). They always start on a new line and typically stack
on top of one another.
• Purpose: These elements define large sections or blocks of content.
1. Paragraphs <p>
• Used to define a block of text as a paragraph.
• Example:
<p>This is a paragraph of text in HTML.</p>
2. Lists: <ul> and <li>
• <ul> is used for unordered (bulleted) lists, and <li> defines each list item.
• Example:
html
Copy code
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
3. Headings <h1> to <h6>, Articles <article>
• Headings are used to define the structure of your content, with <h1> being the most
important and <h6> the least.
• <article> is used for self-contained content like blog posts.
• Example:
html
Copy code
<h1>Main Heading</h1>
<h2>Subheading</h2>
<article>
<h3>Article Title</h3>
<p>Article content goes here.</p>
</article>
4. Sections <section>
• Used to divide a page into thematic sections.
• Example:
html
Copy code
<section>
<h2>Section Title</h2>
<p>Content within this section.</p>
</section>
5. Long Quotes <blockquote>
• Defines a long quotation from another source.
• Example:
html
Copy code
<blockquote>
This is a long quote from another source.
</blockquote>
6. Division <div>
• A generic container used to group HTML elements.
• Example:
html
Copy code
<div>
<p>This is a paragraph inside a div.</p>
</div>
7. Form <form>
• Used to collect user input.
• Example:
html
Copy code
<form action="/submit">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<input type="submit" value="Submit">
</form>
8. Table <table>
• Defines a table structure to display data.
• Example:
html
Copy code
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
These are the basic HTML tags listed in your image. Each tag serves a specific
purpose in structuring and organizing web content.
2. Inline Elements
• Definition: Inline elements do not start on a new line and only take up as much width as
their content. They are used within block-level elements to format or style specific pieces of
content.
• Purpose: These elements are used to style or mark small pieces of content within a block.
Breakdown:
1. Links <a>: This creates a clickable hyperlink.
2. Image <img>: Displays an image with an alternate text description.
3. Span <span>: A generic inline container for text or other elements.
4. Button <button>: Creates a clickable button.
5. Input <input>: Used to create a text input field.
6. Label <label>: Defines a label for form controls (such as an input field).
7. Textarea <textarea>: Defines a multi-line text input area.
8. Emphasized words <em>: Marks text with emphasis, typically italicized.
9. Important words <strong>: Marks important text, typically bolded.
10. Short quotes <q>: Defines a short, inline quotation.
11. Strong <strong>: Adds strong importance to the text, making it bold.
3.Form Elements
• Definition: Form elements are used to collect user input and data through the web page.
They often include elements that allow interaction and submission of information.
• Purpose: Collect and process user data.
• Examples:
o <form>: Defines the form element itself.
o <input>: Defines a variety of input fields like text, password, email, radio buttons,
checkboxes, etc.
o <textarea>: Defines a multi-line text input field.
o <select>: Creates a dropdown list.
o <option>: Specifies options within a <select> dropdown.
o <button>: Defines a clickable button.
o <label>: Defines a label for form controls, improving accessibility.
o <fieldset>: Groups related form elements.
o <legend>: Provides a caption for the <fieldset>
4. Types of HTML Elements
HTML elements are the building blocks of web pages, and they define the structure, content, and
behavior of a website. Elements are represented by tags and can be divided into different types
based on their purpose and behavior. Here’s a breakdown of the main types of HTML elements:
1. Block-Level Elements
• Definition: Block-level elements occupy the full width of their parent container (like the
browser window or a <div>). They always start on a new line and typically stack on top of
one another.
• Purpose: These elements define large sections or blocks of content.
• Examples:
o <div>: Generic container for grouping content.
o <p>: Paragraph of text.
o <h1>, <h2>, ... <h6>: Headings from largest (<h1>) to smallest (<h6>).
o <ul>, <ol>, <li>: Lists (unordered, ordered, and list items).
o <article>: Self-contained block of content, such as a blog post.
o <section>: Logical grouping of content within a page.
o <header>: Introductory content, usually containing navigation links or a logo.
o <footer>: Footer of a page or section.
o <nav>: Navigation links block.
o <form>: Group of form elements for user input.
Characteristics:
• Always start on a new line.
• Can contain other block-level and inline elements.
2. Inline Elements
• Definition: Inline elements do not start on a new line and only take up as much width as
their content. They are used within block-level elements to format or style specific pieces of
content.
• Purpose: These elements are used to style or mark small pieces of content within a block.
• Examples:
o <span>: Generic inline container, often used for styling small portions of text.
o <a>: Anchor element, used to create hyperlinks.
o <img>: Image element, used to embed images in the content.
o <strong>: Emphasizes strong text (bold).
o <em>: Emphasizes text (italic).
o <code>: Represents a snippet of code.
o <br>: Line break, creates a new line within text.
o <small>: Represents smaller text (usually for fine print or notes).
o <b>, <i>: Used for bold and italic text (although <strong> and <em> are semantically
preferred).
Characteristics:
• Do not start on a new line.
• Take up only as much space as needed by the content.
• Can only contain other inline elements, not block-level elements.
4. Form Elements
• Definition: Form elements are used to collect user input and data through the web page.
They often include elements that allow interaction and submission of information.
• Purpose: Collect and process user data.
• Examples:
o <form>: Defines the form element itself.
o <input>: Defines a variety of input fields like text, password, email, radio buttons,
checkboxes, etc.
o <textarea>: Defines a multi-line text input field.
o <select>: Creates a dropdown list.
o <option>: Specifies options within a <select> dropdown.
o <button>: Defines a clickable button.
o <label>: Defines a label for form controls, improving accessibility.
o <fieldset>: Groups related form elements.
o <legend>: Provides a caption for the <fieldset>.
Characteristics:
• Used for user interaction and data collection.
• Typically wrapped inside a <form> element that handles data submission.
5. Semantic Elements
• Definition: Semantic elements describe their meaning clearly to both the browser and
developers. They improve the structure and readability of HTML and provide better
accessibility for users and search engines.
• Purpose: Enhance the clarity of document structure and improve accessibility.
• Examples:
o <article>: Represents self-contained content like articles or blog posts.
o <section>: Groups related content.
o <header>: Defines the introductory section of a document or section.
o <footer>: Defines the footer section of a document or section.
o <nav>: Defines navigation links.
o <aside>: Represents content related to the main content, such as sidebars or
advertisements.
===========================================================================
3. Define table and its attributes with an example program
4. What is HTML Injection and Clickjacking ?
5. Explain Global attributes concept
UNIT – 2
1. Explain conditional and looping statements
<html>
<body>
<p id="demo"></p>
<script>
let day = "Wednesday" ;
switch (day) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
}
document.getElementById("demo").innerHTML = "Today is " + day;
</script>
</body>
</html>
Program:
<html>
<body>
<script>
for (var i = 0; i < 5; i++){
console.log(i);
}
</script>
</body>
</html>
Program:
<script>
let i=0;
do
{ console.log(i);
i++;
}while (i < 5)
</script>
15. sort()
Sorts the elements of an array in place.
javascript
Copy code
let arr = [3, 1, 4, 2];
arr.sort(); // Sorts in ascending order by default
console.log(arr); // Output: [1, 2, 3, 4]
16. reverse()
Reverses the array in place.
javascript
Copy code
let arr = [1, 2, 3];
arr.reverse(); // Reverses the array
console.log(arr); // Output: [3, 2, 1]
17. join()
Joins all elements of an array into a string.
javascript
Copy code
let arr = ['Hello', 'World'];
let str = arr.join(' '); // Joins with a space
console.log(str); // Output: "Hello World"
20. fill()
Fills all elements of an array with a static value.
javascript
Copy code
let arr = [1, 2, 3];
arr.fill(0); // Fills the entire array with 0
console.log(arr); // Output: [0, 0, 0]
These examples cover a wide range of useful operations on arrays in JavaScript!
re array with 0
console.log(numbers); // Output: [0, 0, 0, 0]