Class 02 - 075645
Class 02 - 075645
Forms are used to collect user input in a web page — such as registration info, feedback, login details,
etc.
🔸 <form> Tag
Attribute Description
method GET or POST (GET shows data in URL, POST hides it)
🔸
Common <input> Types
Type Usage Example
1
Type Usage Example
🔹 <label> Tag
<label for="username">Username:</label>
<input type="text" id="username" name="username" />
🔹 <textarea> Tag
🔹
<select> and <option>
🔹
<fieldset> and <legend>
<fieldset>
<legend>Personal Info</legend>
<label for="name">Name:</label>
<input type="text" id="name" />
</fieldset>
✅
Form Validation (Basic HTML Validation)
2
Attribute Use
<label for="email">Email:</label>
<input type="email" id="email" required />
📄
Full Form Example:
<!DOCTYPE html>
<html>
<head>
<title>HTML Form Example</title>
</head>
<body>
<h2>Registration Form</h2>
3
<label for="dob">Date of Birth:</label><br />
<input type="date" id="dob" name="dob" /><br /><br />
<fieldset>
<legend>Preferences</legend>
🧾
HTML Semantic HTML5 Tags
🔹
What is Semantic HTML?
Semantic HTML uses meaningful tags to describe the purpose of the content. These tags help:
🧱
Structure Elements in HTML5
4
Tag Purpose
<header> Represents the top section of a page or section (usually includes logo, title, nav)
<main> Contains the main content of the document (only one per page)
<aside> Sidebars, advertisements, or related links – content indirectly related to the main content
<!DOCTYPE html>
<html>
<head>
<title>Semantic HTML Example</title>
</head>
<body>
<header>
<h1>My Website</h1>
<nav>
<a href="#home">Home</a>
<a href="#services">Services</a>
<a href="#contact">Contact</a>
</nav>
</header>
<main>
<section id="home">
<h2>Welcome!</h2>
<p>This is the homepage of our website.</p>
</section>
<section id="services">
<article>
<h3>Web Development</h3>
<p>We build modern and responsive websites.</p>
</article>
<article>
<h3>Graphic Design</h3>
<p>Creative designs for logos, banners, and more.</p>
</article>
5
</section>
<aside>
<h4>Related Links</h4>
<ul>
<li><a href="#">HTML Tutorials</a></li>
<li><a href="#">CSS Guides</a></li>
</ul>
</aside>
</main>
<footer>
<p>© 2025 My Website. All rights reserved.</p>
</footer>
</body>
</html>
Tag Purpose
Example:
<div class="card">
<h2>Title</h2>
<p>
This is a <span style="color: red">highlighted</span> text inside a
paragraph.
</p>
</div>
🧠
Quick Summary:
Semantic Tag Meaning
6
Semantic Tag Meaning
<nav> Navigation
Multimedia in HTML allows you to embed audio, video, and other interactive content like external
webpages, animations, or PDFs into your site.
🎵
1. Audio Element
🔹
Basic Syntax:
<audio controls>
<source src="sound.mp3" type="audio/mpeg" />
Your browser does not support the audio element.
</audio>
🔹
Important Attributes:
Attribute Description
preload Suggests how the audio should load (auto, metadata, none)
🎬
2. Video Element
7
The <video> tag is used to embed videos.
🔹 Basic Syntax:
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
🔹 Key Attributes:
Attribute Description
🎥
Example with poster:
<video controls poster="thumbnail.jpg">
<source src="sample.mp4" type="video/mp4" />
</video>
🌐
3. Embedding External Content
🔹
<iframe> — Embed another HTML page inside the current page.
• Use MP3 for audio, MP4 for video (they are widely supported).
8
• Always provide a fallback message for unsupported browsers.
• Use iframe to embed maps, videos (like YouTube), or other pages.
✅ Summary Table
Element Used for Important Attributes
🧾 HTML Attributes
HTML attributes provide extra information about elements. They are always specified inside the opening
tag, and usually come in name="value" pairs.
🔹
Global Attributes
Description Example
Attribute
9
💡 Examples of Global Attributes
<p
id="welcome"
class="highlight"
title="Welcome message"
style="font-size: 18px"
>
Welcome to my website!
</p>
<button data-user-id="42">Click Me</button>
<div>
<h2>Block Title</h2>
<p>Block paragraph inside div.</p>
</div>
📋
Summary Table
Concept Explanation
10
🧾 HTML Class 12: HTML Entities
They always start with an ampersand & and end with a semicolon ;.
Some characters like <, >, and & are part of HTML syntax. To display them as normal text (instead of
being interpreted by the browser), we use entities.
© © Copyright
™ ™ Trademark
✏
Examples in Code
11
<p>10 < 20 is true.</p>
<p>Use "double quotes" and 'single quotes' properly.</p>
<p>© 2025 MyCompany. All rights reserved.</p>
Output:
10 < 20 is true.
Use "double quotes" and 'single quotes' properly.
© 2025 MyCompany. All rights reserved.
🧠 Tips:
✅ Summary
• HTML Entities are used to display characters that are reserved in HTML.
• They help prevent misinterpretation by the browser.
• Always start with & and end with ;.
🧾
HTML Comments
🔹
What Are HTML Comments?
HTML comments are notes or explanations that you write inside your HTML code but are not displayed
on the web page.
🧩
Syntax of a Comment:
<!-- This is a comment -->
🎯
When and Why to Use Comments
Purpose Example
🔍
<!-- This section handles the user profile -
Explain complex code
->
✅
Mark TODOs or future updates <!-- TODO: Add responsive design -->
12
Purpose Example
🧑💻 Help team members understand the <!-- Navigation bar starts here -->
code
✏ Example in Code:
<!DOCTYPE html>
<html>
<head>
<title>HTML Comments</title>
</head>
<body>
<!-- This is the main heading -->
<h1>Welcome to My Website</h1>
✅
Summary
Accessibility means designing web pages so that everyone, including people with disabilities, can
easily use and navigate them — using screen readers, keyboard-only navigation, or assistive
technologies.
📸
1. alt Text for Images
13
✅ Good Example:
<img src="dog.jpg" alt="Golden retriever playing in the park">
❌ Bad Example:
<img src="dog.jpg">
Semantic HTML tags describe the structure and meaning of web content, making it easier for assistive
technologies to read and understand the page.
Tag Purpose
Example:
<main>
<article>
<h2>How to Bake a Cake</h2>
<p>Follow these simple steps to bake a cake.</p>
</article>
</main>
Screen readers can understand this better than just using <div> and <span> everywhere.
🏷
3. Introduction to ARIA Attributes
14
ARIA = Accessible Rich Internet Applications
ARIA attributes provide extra information to assistive technologies.
Attribute Use
Example:
<button aria-label="Close">X</button>
✅ Summary
Topic Purpose
🧾
HTML Best Practices
• Better readability
• Easier debugging
• Improved collaboration
• Better SEO and accessibility
🔹
1. Indentation and Formatting
➡
Always indent nested elements properly. This helps you (and others) understand the structure of your
code.
❌
Bad Example:
<html><body><h1>Title</h1><p>Paragraph</p></body></html>
✅
Good Example:
15
<html>
<body>
<h1>Title</h1>
<p>Paragraph</p>
</body>
</html>
🛠 Use tools like VS Code to auto-format code using extensions like Prettier.
Example:
<!-- Navigation bar -->
<nav>
<ul>
<li><a href="#home">Home</a></li>
</ul>
</nav>
🔹
3. Avoid Deprecated Tags
❌ ✅
Deprecated Tag Use Instead
🔎
Focus on semantic HTML and use CSS for styling.
🔹
4. Validate Your HTML
16
Use the W3C HTML Validator to check your code for errors or warnings: https://validator.w3.org
👉
✅ It checks:
✅ Summary
Best Practice Why It’s Important
17