Elements, Tags, and Attributes
Complete reference for HTML elements — live practice tasks appear as each tag group is completed.
2. Empty Tags and Container Tags
HTML tags are categorized into two types based on whether they hold content or not:
Container Tags (Paired)
Have opening + closing tag, contain content.
<p>...</p><h1>...</h1><b>...</b><a>...</a><div>...</div><table>...</table>Empty Tags (Self-closing)
No closing tag, no content inside.
<br> — Line break<hr> — Horizontal rule<img> — Image<input> — Input field<meta> — Metadata<link> — External resource<!-- Container Tag Example -->
<p>This paragraph has opening and closing tags.</p>
<!-- Empty Tag Examples -->
<br>
<hr>
<img src="image.jpg" alt="My Image"><p> are container tags, while break tags like <br> and <hr> are empty tags.3. Body Tag and Attributes
The <body> tag defines the main visible content of a web page. Everything displayed on screen goes inside this tag.
<body bgcolor="lightyellow" text="darkblue"
background="bg.jpg">
<h1>Welcome to My Page</h1>
<p>This is the body content.</p>
</body>| Attribute | Description |
|---|---|
bgcolor | Sets the background color of the page |
text | Sets the default text color |
background | Sets a background image |
topmargin | Top margin of the page |
leftmargin | Left margin of the page |
bgcolor attribute will be used directly in your first profile project in Section 6!4. <p> Tag and Its Attributes
The <p> tag defines a paragraph. Browsers automatically add margin before and after each paragraph.
<p>This is a simple paragraph.</p>
<p align="center">This paragraph is center-aligned.</p>
<p align="right">This paragraph is right-aligned.</p>
<p align="justify">This paragraph text is justified.
It stretches the text so each line has equal width.</p>| Attribute | Description |
|---|---|
align | left (default), center, right, justify |
Important: HTML ignores extra white spaces and line breaks in source code. Multiple spaces become one. Use <br> for breaks and for extra spaces.
align="center" attribute is widely used for headings and introductory text.5. <pre> Tag
The <pre> tag defines preformatted text. It preserves spaces and line breaks exactly as written. Text is displayed in a fixed-width font (Courier).
<pre>
Name Age City
---- --- ----
Rahul 20 Delhi
Priya 22 Mumbai
Amit 19 Jaipur
</pre>Unlike <p>, the <pre> tag does not collapse spaces or line breaks.
<p>This has extra spaces.</p>
<!-- Browser shows: "This has extra spaces." -->
<pre>This has extra spaces.</pre>
<!-- Browser shows: "This has extra spaces." --><pre> tag is essential whenever you want to display formatted poems, quotes, or code blocks without writing multiple line break tags.6. <br> Tag & Practice Project
The <br> tag inserts a line break. It is an empty tag (no closing tag). Useful for addresses, poems, or anywhere you need a line break without a new paragraph.
<p>
Knobly Education<br>
123, Main Street<br>
New Delhi - 110001<br>
India
</p>
<!-- Poem example -->
<p>
Twinkle twinkle little star,<br>
How I wonder what you are.<br>
Up above the world so high,<br>
Like a diamond in the sky.
</p>| <br> | <p> |
|---|---|
| Only adds a line break | Adds line break with margin |
| Empty tag (no closing) | Container tag (has closing) |
| No extra spacing | Adds space above and below |
Task 1: My Profile Page
Ab aapne body bgcolor, p, pre, br, aur hr tags seekh liye hain! In tags ka use karke apna personal developer profile page banayein — bio, favorite quote in pre tag, aur contact address.
<body bgcolor><p align="center"><pre><br><hr>7. <hr> Tag and Attributes
The <hr> tag creates a horizontal rule (line) across the page. It is an empty tag (no closing tag). Used to separate content sections visually.
<!-- Basic horizontal line -->
<hr>
<!-- HR with width attribute -->
<hr width="50%">
<hr width="300">
<!-- HR with size (thickness) -->
<hr size="5">
<hr size="10">
<!-- HR with color -->
<hr color="red">
<hr color="#3b82f6">
<!-- HR with alignment -->
<hr align="left" width="50%">
<hr align="center" width="70%">
<hr align="right" width="40%">
<!-- HR without shadow (noshade) -->
<hr noshade>
<hr noshade size="3" color="darkblue" width="80%">
<!-- Complete Example -->
<h2>Chapter 1: Introduction</h2>
<p>This is the first chapter content.</p>
<hr color="orange" size="3" width="90%" align="center" noshade>
<h2>Chapter 2: Getting Started</h2>
<p>This is the second chapter content.</p>| Attribute | Description |
|---|---|
width | Width of the line in pixels or percentage (e.g., width="50%" or width="300") |
size | Thickness/height of the line in pixels (e.g., size="5") |
color | Color of the line (e.g., color="red" or color="#ff0000") |
align | Alignment: left, center (default), or right |
noshade | Removes the 3D shadow effect, makes line flat and solid |
HR vs BR Comparison:
<hr> — Draws a visible horizontal line to separate sections<br> — Only adds an invisible line break (no visible line)<hr color="red" size="3" width="80%" noshade>. The noshade attribute removes the default shadow effect for a cleaner look.9. HTML Formatting Elements
HTML provides several tags for formatting text:
<b>Bold Text</b>
<strong>Strong/Important Text</strong>
<i>Italic Text</i>
<em>Emphasized Text</em>
<u>Underlined Text</u>
<s>Strikethrough Text</s>
<del>Deleted Text</del>
<ins>Inserted Text</ins>
<mark>Highlighted Text</mark>
<small>Smaller Text</small>
<big>Bigger Text</big>
<sub>Subscript</sub> like H<sub>2</sub>O
<sup>Superscript</sup> like x<sup>2</sup>
<code>Inline Code</code>
<kbd>Keyboard Input</kbd>
<abbr title="HyperText Markup Language">HTML</abbr>
<blockquote>This is a blockquote.</blockquote>
<address>Contact: student@example.com</address>Quick Reference:
<b> — Bold<strong> — Strong<i> — Italic<em> — Emphasized<u> — Underline<del> — <mark> — Highlighted<small> — Small<sub> — H2O<sup> — x2<sub> and algebraic expressions like a2 + b2 using <sup>.10. Heading Tags (h1-h6)
HTML provides six levels of headings. <h1> is the largest and most important, <h6> is the smallest.
<h1>Heading 1 - Most Important</h1>
<h2 id="heading-2">Heading 2</h2>
<h3 id="heading-3">Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6 - Least Important</h6>
<h1 align="center">Centered Heading</h1>
<h2 id="right-aligned-heading" align="right">Right-aligned Heading</h2>H1 Heading
H2 Heading
H3 Heading
H4 Heading
H5 Heading
H6 Heading
Rules: Use only one <h1> per page. Do not skip heading levels. Headings help SEO.
<h1>Main Topic</h1>, followed by sub-headings <h2>Sub-Topic</h2>.11. <center> Tag and Alignment
The <center> tag is a container tag used to horizontally center-align text, headings, paragraphs, images, or entire sections on a web page.
<!-- Centering headings -->
<center>
<h1>Welcome to Knobly Education</h1>
<h3>Learn Web Development Step by Step</h3>
</center>
<!-- Centering formatted text -->
<center>
<p><b><u>Important Notice:</u></b> All exams start at 10:00 AM.</p>
</center>
<!-- Difference between <center> tag and align="center" attribute -->
<center><h3>Centered using <center> container tag</h3></center>
<h3 align="center">Centered using align="center" attribute</h3>
<!-- Centering images and content blocks -->
<center>
<img src="logo.png" alt="Logo" width="100">
<p>Empowering Students Across India</p>
<hr width="50%">
</center>Visual Alignment Demo:
⚠️ O-Level Exam Note:
The <center> tag is deprecated in HTML5 (where CSS text-align: center; is preferred). However, in NIELIT O-Level (M2-R5) and CCC exams, question papers frequently test the <center> tag and align="center" attribute!
Task 2: Basic HTML Tags & Formatting
Formatting tags (b, i, u), Headings (h1-h6), aur <center> tag complete hone ke baad ab Task 2 solve karein — bold, italic, underline, center-aligned text, preformatted text, aur multi-level headings.
<h1>, <h2><center><b>, <i>, <u><pre><br><hr>12. <font> Tag and Attributes
The <font> tag is used to change the color, size, and face (typeface) of text. It is a container tag that wraps around the text you want to style.
<!-- Font with color -->
<font color="red">This text is red.</font>
<font color="#3b82f6">This text is blue.</font>
<font color="green">This text is green.</font>
<!-- Font with size (1 to 7, default is 3) -->
<font size="1">Size 1 - Smallest</font>
<font size="2">Size 2</font>
<font size="3">Size 3 - Default</font>
<font size="4">Size 4</font>
<font size="5">Size 5</font>
<font size="6">Size 6</font>
<font size="7">Size 7 - Largest</font>
<!-- Font with face (typeface/font family) -->
<font face="Arial">This is Arial font.</font>
<font face="Times New Roman">This is Times New Roman.</font>
<font face="Courier New">This is Courier New (monospace).</font>
<font face="Verdana">This is Verdana font.</font>
<!-- Combining all attributes -->
<font color="darkblue" size="5" face="Arial">
Welcome to Knobly Education!
</font>
<!-- Nested font tags -->
<font color="red" size="4">
This is <font face="Courier New">mixed</font> styling.
</font>
<!-- Font used with other tags -->
<h2><font color="orange">Colored Heading</font></h2>
<p><font color="green" size="4" face="Verdana">Styled paragraph text.</font></p>| Attribute | Description |
|---|---|
color | Text color — name (red, blue) or hex code (#ff0000) |
size | Text size from 1 (smallest) to 7 (largest). Default is 3 |
face | Font family/typeface — Arial, Times New Roman, Courier New, Verdana, etc. |
Font Size Reference:
⚠️ Note:
The <font> tag is deprecated in HTML5 — modern websites use CSS for styling. But it is still important for O-Level exams and understanding HTML fundamentals!
<h1><font color="red" face="Arial">Welcome</font></h1>. Try different sizes and faces to see the visual difference.13. <img> Tag and Attributes
The <img> tag embeds images. It is a self-closing (empty) tag.
<img src="photo.jpg" alt="A photo" width="300" height="200">
<!-- Image with border -->
<img src="pic.jpg" alt="Picture" border="2">
<!-- Image as a link -->
<a href="https://knoblyweb.in">
<img src="logo.png" alt="Knobly" width="100">
</a>
<!-- Image with text wrap -->
<img src="photo.jpg" alt="Photo" align="left" hspace="10" vspace="10">
<p>This text wraps around the image.</p>| Attribute | Description |
|---|---|
src | Path/URL of the image (required) |
alt | Alternative text if image fails (required) |
width | Width in pixels or percentage |
height | Height in pixels or percentage |
border | Border around the image |
align | left, right, top, middle, bottom |
hspace | Horizontal space around image |
vspace | Vertical space around image |
Task 3: India - A Diverse Nation
Ab aapne <img> tag seekh liya hai! Task 3 me India ke bare me article banayein jisme headings, font colors, aur India ka map image embedded ho.
<img> (src, alt, align)<h1> - <h5><font color><p><hr>14. <marquee> Tag and Attributes
The <marquee> tag creates scrolling/moving text or images on a webpage. It is a container tag that makes its content move automatically.
<!-- Basic scrolling text (left to right default) -->
<marquee>Welcome to Knobly Education!</marquee>
<!-- Scroll Amount (speed control) -->
<marquee scrollamount="2">Slow scrolling text</marquee>
<marquee scrollamount="10">Fast scrolling text</marquee>
<marquee scrollamount="20">Very fast scrolling!</marquee>
<!-- Behavior: scroll, slide, alternate -->
<marquee behavior="scroll">Scroll (default) - loops continuously</marquee>
<marquee behavior="slide">Slide - stops at the edge</marquee>
<marquee behavior="alternate">Alternate - bounces back and forth</marquee>
<!-- Direction: left, right, up, down -->
<marquee direction="right">Moving Right →</marquee>
<marquee direction="up" height="80">Moving Up ↑</marquee>
<marquee direction="down" height="80">Moving Down ↓</marquee>
<!-- Loop count -->
<marquee loop="3">This scrolls only 3 times.</marquee>
<marquee loop="1">This scrolls only once!</marquee>
<marquee loop="-1">Infinite loop (default)</marquee>
<!-- Height and Width -->
<marquee width="50%" height="50" bgcolor="lightyellow">
Half-width marquee with background color
</marquee>
<!-- Combined Example -->
<marquee behavior="alternate" scrollamount="5"
bgcolor="#1e293b" width="100%" height="40">
<font color="white" size="4">★ Breaking News: HTML is Fun! ★</font>
</marquee>
<!-- Image in marquee -->
<marquee scrollamount="8" behavior="alternate">
<img src="logo.png" alt="Logo" width="60">
</marquee>| Attribute | Description |
|---|---|
scrollamount | Speed of scrolling in pixels per frame (default: 6). Higher = faster |
behavior | scroll (default, continuous), slide (stops at edge), alternate (bounces) |
direction | Scroll direction: left (default), right, up, down |
loop | Number of times to repeat. -1 or default = infinite |
height | Height of the marquee area in pixels or percentage |
width | Width of the marquee area in pixels or percentage |
bgcolor | Background color of the marquee area |
scrolldelay | Delay between each frame in milliseconds (default: 85) |
Behavior Comparison:
scroll — Text scrolls continuously in one direction and repeats from the other sideslide — Text slides in and stops when it reaches the edgealternate — Text bounces back and forth between the edges like a ping-pong ball⚠️ Note:
The <marquee> tag is deprecated in HTML5 — modern websites use CSS animations. But it is still asked in O-Level exams and useful for learning text animation concepts!
<marquee behavior="alternate" scrollamount="5">Breaking News!</marquee>. Try changing scrollamount to see speed differences.Task 4: Indian History Timeline
Image alignment (align='right'), marquee, font size/color, aur historical period sections ka use karke Indian History Timeline banayein.
<img align="right"><marquee><font face/size/color><h1> - <h3><hr color>15. <a> Anchor Tag
The <a> tag creates hyperlinks.
<!-- External link -->
<a href="https://www.google.com">Visit Google</a>
<!-- Open in new tab -->
<a href="https://www.google.com" target="_blank">Open in New Tab</a>
<!-- Email link -->
<a href="mailto:info@knoblyweb.in">Send Email</a>
<!-- Phone link -->
<a href="tel:+919876543210">Call Us</a>
<!-- Bookmark link (same page) -->
<a href="#section3">Jump to Section 3</a>
...
<h2 id="section3">Section 3</h2>
<!-- Download link -->
<a href="notes.pdf" download>Download Notes</a>| Attribute | Description |
|---|---|
href | URL of the link destination (required) |
target | _self (same tab), _blank (new tab), _parent, _top |
title | Tooltip text on hover |
download | Downloads file instead of navigating |
name | Name of anchor (for bookmarks) |
Task 7: Simple Webpage with Bookmarks & Navigation
Hyperlinks aur internal bookmarks (<a href='#about'>, <a name='about'>, <a href='#top'>) seekhne ke baad bina CSS ke ek pure semantic clickable website banayein.
<a href>target="_blank"Page Bookmarks (<a name>)mailto:<h1> - <h4><p><hr>17. Table Tag and Attributes (Complete Master Guide)
HTML me data ko grid format me yani Rows (पंक्तियाँ) aur Columns (कॉलम) me tabular roop se organize karne ke liye Table tags ka use kiya jaata hai. Ek standard HTML table 5 mukhya tags se milkar banti hai:
<table>Main Table Container
<caption>Table Title / Heading
<tr>Table Row (Horizontal)
<th>Header Cell (Bold + Center)
<td>Data Cell (Normal + Left)
A. <table> Tag (Parent Container)
Yeh table ka main boundary tag hota hai. Sabhi rows aur cells isi ke andar aate hain. Iske attributes poori table ke appearance, size, border, aur internal/external spacing ko define karte hain:
| Attribute | Description |
|---|---|
border | Table ke borders ki motai pixels me (jaise border="1" ya border="2"). Agar border="0" ho toh borders invisible hote hain. |
cellpadding | Cell ke border aur text content ke beech ka internal space / padding (pixels me, jaise cellpadding="8"). |
cellspacing | Do adjacent cells ke beech ka external gap / doori (pixels me, jaise cellspacing="0" sharp grid look ke liye). |
width | Table ki poori chaudai (percentage jaise width="100%" ya pixels me width="600"). |
height | Table ki vertical unchai (pixels me, jaise height="250"). |
align | Poori table ka webpage par horizontal alignment ("left", "center", "right"). |
bgcolor | Poori table ka background color (color name ya HEX code, jaise bgcolor="#f8fafc"). |
bordercolor | Table ke borders ka color specify karta hai (jaise bordercolor="#0284c7"). |
background | Table ke background me image lagane ke liye (jaise background="pattern.jpg"). |
<!-- <table> tag ke attributes ka live use -->
<table border="2" cellpadding="10" cellspacing="2" width="100%" align="center" bgcolor="#f8fafc" bordercolor="#0284c7">
<caption><b>Products & Price List</b></caption>
<tr bgcolor="#0284c7">
<th><font color="white">Item</font></th>
<th><font color="white">Quantity</font></th>
<th><font color="white">Price</font></th>
</tr>
<tr align="center">
<td>Mechanical Keyboard</td>
<td>5</td>
<td>₹2,500</td>
</tr>
<tr align="center">
<td>Optical Mouse</td>
<td>10</td>
<td>₹850</td>
</tr>
</table>B. <caption> Tag (Table Title & Heading)
Table ka title ya main topic heading display karne ke liye <caption> tag ka use hota hai. Yeh hamesha <table> tag ke turant baad pehla child tag hona chahiye.
| Attribute | Description |
|---|---|
align | Caption ki vertical position set karta hai: "top" (table ke upar, default) ya "bottom" (table ke neeche). |
<table border="1" width="80%" align="center" cellpadding="6">
<!-- Caption table ke upar title display karega -->
<caption align="top"><b>Monthly Sales Report - 2026</b></caption>
<tr bgcolor="#e2e8f0" align="center">
<th>Month</th>
<th>Revenue</th>
</tr>
<tr align="center">
<td>January</td>
<td>₹45,000</td>
</tr>
</table>C. <tr> Tag (Table Row)
<tr> ka full form Table Row hai. Yeh table me ek horizontal line (row) banata hai. Row ke andar ya toh <th> (headings) aate hain ya <td> (data cells). Iske attributes us row ke sabhi cells par ek sath apply ho jaate hain:
| Attribute | Description |
|---|---|
align | Us row ke sabhi cells ka horizontal text alignment: "left", "center", "right", "justify". |
valign | Us row ke sabhi cells ka vertical alignment: "top" (upar), "middle" (beech me, default), "bottom" (neeche). |
bgcolor | Us specific row ka background color (jaise header row ya zebra striping ke liye). |
bordercolor | Us specific row ke border ka color specify karta hai. |
<table border="1" width="100%" cellpadding="8">
<!-- Row 1: Header row with purple background & centered text -->
<tr bgcolor="#7e22ce" align="center">
<th><font color="white">Emp ID</font></th>
<th><font color="white">Employee Name</font></th>
<th><font color="white">Department</font></th>
</tr>
<!-- Row 2: Data row with align="center" and light purple background -->
<tr bgcolor="#faf5ff" align="center" valign="middle">
<td>E-101</td>
<td>Amit Sharma</td>
<td>Web Development</td>
</tr>
<!-- Row 3: Data row with different alignment -->
<tr align="center" valign="middle">
<td>E-102</td>
<td>Pooja Verma</td>
<td>UI/UX Design</td>
</tr>
</table>D. <th> Tag (Table Header Cell)
<th> ka full form Table Header hai. Yeh table ke columns ya rows ki headings ke liye use hota hai. By default iska text Bold (गाढ़ा) hota hai aur Center Aligned hota hai.
| Attribute | Description |
|---|---|
colspan | Horizontal columns ko merge karne ke liye number specify karta hai (jaise colspan="3" teen columns merge karega). |
rowspan | Vertical rows ko merge karne ke liye number specify karta hai (jaise rowspan="2" do rows merge karega). |
align | Header cell ka horizontal text alignment: "left", "center", "right". |
valign | Vertical text alignment: "top", "middle", "bottom". |
bgcolor | Header cell ka specific background color. |
width | Header cell ki width pixels ya percentage me. |
height | Header cell ki unchai (height in pixels). |
nowrap | Header text ko bina wrap hue single line me rakhta hai. |
<table border="1" width="100%" cellpadding="8" cellspacing="0">
<tr bgcolor="#0f766e">
<!-- colspan="2" se do columns merge hokar ek broad header banenge -->
<th colspan="2"><font color="white">Student Details</font></th>
<!-- normal th -->
<th bgcolor="#047857"><font color="white">Grade</font></th>
</tr>
<tr align="center">
<td>Roll No: 101</td>
<td>Rahul Kumar</td>
<td>A+</td>
</tr>
</table>E. <td> Tag (Table Data Cell)
<td> ka full form Table Data hai. Yeh table ka basic data container cell hota hai jisme actual text, numbers, images, ya links store hote hain. By default iska text Regular (Normal font) aur Left Aligned hota hai.
| Attribute | Description |
|---|---|
colspan | Data cell ko horizontal roop se multiple columns me merge karna (jaise colspan="2"). |
rowspan | Data cell ko vertical roop se multiple rows me merge karna (jaise rowspan="2"). |
align | Cell content ka horizontal alignment: "left", "center", "right". |
valign | Cell content ka vertical alignment: "top", "middle", "bottom". |
bgcolor | Individual data cell ka custom background color. |
width | Cell ki custom width (pixels ya % me). |
height | Cell ki custom height (pixels me). |
nowrap | Cell text me automatic line break hone se rokna. |
<table border="1" width="100%" cellpadding="8" cellspacing="0">
<tr bgcolor="#334155">
<th><font color="white">State</font></th>
<th><font color="white">City</font></th>
<th><font color="white">Status</font></th>
</tr>
<tr>
<!-- rowspan="2" se Uttar Pradesh 2 rows me merge hoga -->
<td rowspan="2" align="center" bgcolor="#f1f5f9"><b>Uttar Pradesh</b></td>
<td>Lucknow</td>
<td bgcolor="#dcfce7" align="center">Active</td>
</tr>
<tr>
<td>Kanpur</td>
<td bgcolor="#dcfce7" align="center">Active</td>
</tr>
</table>🔍 Quick Comparison: <th> (Header) vs <td> (Data)
| Feature | <th> (Table Header) | <td> (Table Data) |
|---|---|---|
| Default Font Weight | Bold (गाढ़ा) | Regular (सामान्य) |
| Default Text Alignment | Center (बीच में) | Left (बाईं तरफ) |
| Primary Purpose | Column ya Row ki heading batana | Actual data content display karna |
G. Complete Master Table (Colspan, Rowspan & Zebra Styling)
Neeche diye gaye complete code me border, cellpadding, cellspacing, <caption>, bgcolor, colspan, aur rowspan sabhi ka real-world use dekhein:
<table border="1" cellpadding="8" cellspacing="0" width="100%" bgcolor="#ffffff">
<caption align="top"><b>Student Examination Scoreboard 2026</b></caption>
<!-- Top Super-Header using colspan -->
<tr bgcolor="#1e293b" align="center">
<th rowspan="2"><font color="white">Roll No</font></th>
<th rowspan="2"><font color="white">Student Name</font></th>
<th colspan="3"><font color="white">Marks Obtained</font></th>
<th rowspan="2"><font color="white">Status</font></th>
</tr>
<!-- Sub-headers for Subjects -->
<tr bgcolor="#334155" align="center">
<th><font color="white">HTML</font></th>
<th><font color="white">CSS</font></th>
<th><font color="white">JS</font></th>
</tr>
<!-- Student 1 -->
<tr align="center">
<td>101</td>
<td align="left">Aarav Sharma</td>
<td>88</td>
<td>92</td>
<td>85</td>
<td bgcolor="#dcfce7"><font color="#15803d"><b>PASS</b></font></td>
</tr>
<!-- Student 2 with zebra background -->
<tr align="center" bgcolor="#f8fafc">
<td>102</td>
<td align="left">Priya Patel</td>
<td>95</td>
<td>90</td>
<td>94</td>
<td bgcolor="#dcfce7"><font color="#15803d"><b>PASS</b></font></td>
</tr>
</table>Task 5.1: Operating Systems (Table Layout)
Table, border, cellpadding, aur alternating colors ka use karke OS market share table banayein.
<table><tr><th><td>bordercellpaddingTask 5.2: Global Internet Usage Statistics
Rowspan aur Colspan ka advanced use karke regional internet usage data table banayein.
colspan="2"rowspan="2"<caption><th><td>alignTask 5.3: History of the Internet (Table & Timeline)
Description lists, ordered timeline, aur styled data tables (<table border='1'>, <caption>, <tr>, <th>, <td>) ka use karke History of Internet ka educational page banayein.
<table><caption><tr><th><td><dl><ol>fontTask 6: Weekly Study Schedule
Complex multi-row aur multi-column timetable banayein jisme days, timeslots, aur subject cells merged hon.
colspan="5"rowspan="2"bgcolorcellspacing="0"caption18. <frameset> Tag and Attributes
Frame aur frameset: Ek browser window mein multiple HTML documents ko alag areas mein dikhane ke liye purane HTML mein frames use hote the. <frameset> layout banata hai aur <frame> har area ka document select karta hai.
<frameset>, <frame> aur <noframes> HTML5 mein obsolete hain. Inhe purane examples aur exam syllabus samajhne ke liye padhein. Naye layouts mein CSS Grid/Flexbox aur document embedding ke liye <iframe> use karein.<frameset>...</frameset> ek container tag hai. Frameset document mein yeh normal <body> ki jagah aata hai; frame ke andar load hone wali child files mein normal <body> hota hai.
| Attribute | Values / Example | Meaning |
|---|---|---|
| rows | "50%,50%" | "100,*" | "*,2*" | Horizontal rows: upar aur neeche frames. Values height set karti hain. |
| cols | "30%,70%" | "200,*" | "*,*" | Vertical columns: left aur right frames. Values width set karti hain. |
| border (legacy extension) | "0" | "5" | Kuch purane browsers mein frames ke beech border ki thickness. Yeh standard HTML 4 frameset attribute nahi tha; support browser par depend karta tha. |
Rows, columns aur size values
Comma-separated har value ek area batati hai. 100 = 100 pixels, 50% = aadhi available size, * = remaining space. *,* equal parts aur *,2* remaining space ka 1:2 ratio banata hai.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"https://www.w3.org/TR/html4/frameset.dtd">
<html>
<head><title>Two horizontal frames</title></head>
<frameset rows="50%,50%">
<frame src="first.html" title="First page">
<frame src="secondpage.html" title="Second page">
</frameset>
</html><!-- Same structure; use cols instead of rows for left/right areas. -->
<frameset cols="*,*">
<frame src="first.html" title="Left page">
<frame src="secondpage.html" title="Right page">
</frameset>rows="*,*"
cols="*,*"
frameset.html, first.html, secondpage.html aur third.html ko ek folder mein save karein, phir frameset.html browser mein kholein. Relative src filenames usi folder se load honge; single-buffer Web Compiler in child files ko automatically create nahi karta.19. <frame> Tag and Attributes
<frame> ek empty tag hai: iska closing tag nahi hota. Yeh <frameset> ka child hota hai. src se us frame mein dikhne wali HTML file ya URL set hoti hai.
| Attribute | Values / Example | Meaning |
|---|---|---|
| src | "first.html" | Frame ke andar load hone wale document ka path/URL. |
| name | "contentFrame" | Frame ka naam; anchor ka target isi naam par document khol sakta hai. |
| title | "Course content" | Frame ke purpose ka readable description. |
| frameborder | "0" | "1" | 0 = frame border hide, 1 = border show (legacy HTML attribute). |
| noresize | Boolean: noresize | Present hone par user frame boundary drag karke resize nahi kar sakta. noresize="false" bhi present maana jaata hai. |
| scrolling | "yes" | "no" | "auto" | yes = scrollbars request, no = scrollbars hide, auto = zaroorat par; default auto. no se content cut sakta hai. |
| marginwidth / marginheight | "10" / "15" | Frame document ke horizontal / vertical margins, pixels mein. |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"https://www.w3.org/TR/html4/frameset.dtd">
<html>
<head><title>Frame attributes</title></head>
<frameset rows="*,*">
<frame src="first.html" name="menuFrame" title="Menu"
frameborder="0" noresize scrolling="no">
<frame src="secondpage.html" name="contentFrame" title="Content"
frameborder="0" scrolling="auto" marginwidth="10" marginheight="15">
</frameset>
</html>Notebook ka <frameset border="0"> kuch legacy browsers ka extension hai. Standard HTML 4 frame control frameborder="0" hai; upar har frame par diya gaya hai.
Child pages: har file alag save karein
<!DOCTYPE html>
<html><head><title>First page</title></head>
<body>
<h1>First page</h1>
<a href="third.html" target="contentFrame">Open third page in content frame</a>
</body></html><!DOCTYPE html>
<html><head><title>Second page</title></head>
<body><h1>Second page</h1><p>This is the content area.</p></body></html><!DOCTYPE html>
<html><head><title>Third page</title></head>
<body><h1>Third page</h1><p>Another independent HTML document.</p></body></html>scrolling="auto" aur scrolling="no" compare karein. Phir noresize remove karke frame boundary drag karne ka difference dekhein, agar browser legacy frames support karta hai.20. Nested Frames
Ek <frameset> ke andar doosra <frameset> rakhna nested frames kehlata hai. Outer set overall window divide karta hai; inner set sirf apne allotted area ko divide karta hai.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"https://www.w3.org/TR/html4/frameset.dtd">
<html>
<head><title>Nested frames example</title></head>
<frameset rows="*,*">
<frame src="first.html" title="Top page">
<frameset cols="*,*">
<frame src="secondpage.html" name="contentFrame" title="Bottom left page">
<frame src="third.html" title="Bottom right page">
</frameset>
</frameset>
</html>- Outer
rows="*,*"do equal-height rows banata hai. - Top row mein
first.htmlload hoti hai. - Bottom row ka inner
cols="*,*"us area ko do columns mein baantta hai. - Inner frameset ko outer frameset se pehle close karein. Child HTML files normal body use karti hain.
Reference: W3C HTML 4.01: Frames, attributes and nested frame sets.
21. Form Tag, Attributes and Elements
<form>...</form> ek container tag hai jo user input collect karta hai. Iske andar input, textarea, button, fieldset, legend, select aur option use hote hain. <input> empty tag hai; baaki listed controls ke closing tags hote hain.
A. Form attributes aur unki values
| Attribute | Values / Example | Meaning |
|---|---|---|
| name | "registrationForm" | Form ka naam/identifier. Yeh apne aap screen par heading nahi dikhata; heading ya legend alag likhein. |
| action | "/submit" | "https://example.com/register" | Submit hone par data receive karne wale endpoint ka URL. Backend banana alag step hai. |
| method | "get" | "post" (also "dialog") | get data ko URL query mein bhejta hai (default); post request body mein. dialog sirf dialog form ke liye hai. |
| enctype | "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain" | POST data encoding; file uploads ke liye multipart/form-data. Default application/x-www-form-urlencoded. |
| target | "_self" | "_blank" | frame name | Submission response kis browsing area mein khulega. Default _self. |
| autocomplete | "on" | "off" | Browser autofill preference; browser har situation mein isse follow kare yeh guaranteed nahi. |
| novalidate | Boolean: novalidate | Submission par browser ki built-in form validation skip karta hai. |
<form name="registrationForm" action="/submit" method="post">
<!-- Put named form controls here -->
</form>GET vs POST: Search/filter jaise requests ke liye GET useful hai. Password ya private data URL mein na bhejein. POST bhi apne aap encryption nahi karta; real submissions ke liye HTTPS aur server-side validation chahiye. Neeche ke runnable demos submission ko page par hi rok dete hain.
B. Input attributes: type, name aur value
| Attribute | Values / Example | Meaning |
|---|---|---|
| type | "text", "radio", "checkbox", "date", "password", "file", "number", "time", "tel", "email", "submit", "reset" | Input control ka type select karta hai; default text. Har type ka example neeche hai. |
| name | "firstName" | "language" | Submitted data ka key. Normal data controls mein name missing ho to unka value submission mein nahi aata. |
| value | "Student" | "html" | "Log in" | Initial text, radio/checkbox ka submitted value, ya submit/reset button ka label; meaning type par depend karta hai. File input ko arbitrary value nahi de sakte. |
| id | "first-name" | Unique control ID; label ka for isi ID se match karein. |
| placeholder | "Enter your name" | Empty input ka hint; visible label ka replacement nahi. |
| size / maxlength | "30" / "50" | Supported text controls ki visible character width / maximum input length. |
| required | Boolean: required | Supported field ko browser validation mein required banata hai. |
| checked | Boolean: checked | Radio/checkbox ko initially selected karta hai. Unchecked radio/checkbox submit nahi hote. |
| min / max / step | "1" / "100" / "1" | Number, range, date ya time control ki supported limits aur increments. |
| accept / multiple | ".pdf,image/*" / multiple | File picker hint / multiple files selection. Actual upload validate karna server ka kaam hai. |
| readonly / disabled | Boolean attributes | readonly supported text field edit hone se rokta hai; disabled control focus/submit nahi hota. |
type="text" — First name aur Last name
Single-line text field. value se initial text set hota hai.
<form onsubmit="event.preventDefault(); document.getElementById('demo-status').textContent = 'Demo only: no data was sent.';">
<label for="first-name">First name:</label>
<input id="first-name" type="text" name="firstName" value="Student"><br>
<label for="last-name">Last name:</label>
<input id="last-name" type="text" name="lastName" placeholder="Enter last name">
<p id="demo-status" role="status"></p>
</form>type="radio" — Choose your favourite web language
Ek group se ek choice: sab radio controls ka same name, lekin alag value rakhein.
<form onsubmit="event.preventDefault(); document.getElementById('demo-status').textContent = 'Demo only: no data was sent.';">
<p>Choose your favourite web language:</p>
<label><input type="radio" name="language" value="html" checked> HTML</label><br>
<label><input type="radio" name="language" value="css"> CSS</label><br>
<label><input type="radio" name="language" value="js"> JavaScript</label>
<p id="demo-status" role="status"></p>
</form>type="checkbox" — Select your skills
Multiple independent choices select kar sakte hain.
<form onsubmit="event.preventDefault(); document.getElementById('demo-status').textContent = 'Demo only: no data was sent.';">
<label><input type="checkbox" name="skills" value="software"> I am a software developer</label><br>
<label><input type="checkbox" name="skills" value="design"> I am a graphic designer</label>
<p id="demo-status" role="status"></p>
</form>type="date" — Date of birth
Date picker ka display browser/locale par depend karta hai; submitted value YYYY-MM-DD hoti hai.
<form onsubmit="event.preventDefault(); document.getElementById('demo-status').textContent = 'Demo only: no data was sent.';">
<label>Date of birth: <input type="date" name="dob" value="2000-01-15"></label>
<p id="demo-status" role="status"></p>
</form>type="password" — Password field
Typed characters mask hote hain. Yeh masking encryption nahi hai; demo mein real password na daalein.
<form onsubmit="event.preventDefault(); document.getElementById('demo-status').textContent = 'Demo only: no data was sent.';">
<label>Demo password: <input type="password" name="password" autocomplete="new-password" minlength="8"></label>
<p id="demo-status" role="status"></p>
</form>type="file" — Choose a document
File picker kholta hai. Actual upload ke liye POST, multipart/form-data aur backend chahiye.
<form onsubmit="event.preventDefault(); document.getElementById('demo-status').textContent = 'Demo only: no data was sent.';">
<label>Document: <input type="file" name="document" accept=".pdf,image/*"></label>
<p id="demo-status" role="status"></p>
</form>type="number" — Enter your age
Numeric entry; min, max aur step limits set karte hain.
<form onsubmit="event.preventDefault(); document.getElementById('demo-status').textContent = 'Demo only: no data was sent.';">
<label>Age: <input type="number" name="age" min="1" max="120" step="1" value="18"></label>
<p id="demo-status" role="status"></p>
</form>type="time" — Choose a time
Time control; default submitted value hours:minutes hoti hai, seconds bhi ho sakte hain.
<form onsubmit="event.preventDefault(); document.getElementById('demo-status').textContent = 'Demo only: no data was sent.';">
<label>Time: <input type="time" name="meetingTime" value="10:30"></label>
<p id="demo-status" role="status"></p>
</form>type="tel" — Telephone number
Telephone entry / mobile keypad hint; tel apne aap phone-number format validate nahi karta.
<form onsubmit="event.preventDefault(); document.getElementById('demo-status').textContent = 'Demo only: no data was sent.';">
<label>Phone no.: <input type="tel" name="phone" placeholder="Enter phone number"></label>
<p id="demo-status" role="status"></p>
</form>type="email" — Email address
Browser email syntax check karta hai; address exist karta hai ya nahi, yeh verify nahi karta.
<form onsubmit="event.preventDefault(); document.getElementById('demo-status').textContent = 'Demo only: no data was sent.';">
<label>Email: <input type="email" name="email" placeholder="student@example.com" required></label>
<p id="demo-status" role="status"></p>
</form>type="submit" — Submit button
Containing form submit karta hai. value button par dikhne wala text hai; yeh sirf demo hai, real login nahi.
<form onsubmit="event.preventDefault(); document.getElementById('demo-status').textContent = 'Demo only: no data was sent.';">
<input type="submit" value="Log in">
<p id="demo-status" role="status"></p>
</form>type="reset" — Reset button
Form ke controls ko initial/default values par laata hai; har field ko blank karna zaroori nahi.
<form onsubmit="event.preventDefault(); document.getElementById('demo-status').textContent = 'Demo only: no data was sent.';">
<label>Name: <input type="text" name="student" value="Student"></label>
<input type="reset" value="Reset">
<p id="demo-status" role="status"></p>
</form>type="color" — Choose a color
Color picker. Existing guide ka color input bhi yahan available hai.
<form onsubmit="event.preventDefault(); document.getElementById('demo-status').textContent = 'Demo only: no data was sent.';">
<label>Favorite color: <input type="color" name="color" value="#2563eb"></label>
<p id="demo-status" role="status"></p>
</form>type="range" — Choose a level
Slider min aur max ke beech value select karta hai.
<form onsubmit="event.preventDefault(); document.getElementById('demo-status').textContent = 'Demo only: no data was sent.';">
<label>Level: <input type="range" name="level" min="1" max="10" value="5"></label>
<p id="demo-status" role="status"></p>
</form>C. Textarea: multi-line input
<textarea>...</textarea> address, feedback ya message jaise multiple lines ke liye hai. Initial text opening aur closing tags ke beech likhein; value HTML attribute use nahi hota.
| Attribute | Values / Example | Meaning |
|---|---|---|
| name / id | "address" / "address-field" | Submission key aur label association. |
| rows / cols | "3" / "30" | Visible line count / character columns; CSS bhi rendered size badal sakti hai. |
| placeholder / maxlength | "Enter address" / "500" | Hint text aur maximum characters. |
| required / readonly / disabled | Boolean attributes | Validation aur editing/submission behavior control karte hain. |
<label for="address-field">Address:</label><br>
<textarea name="address" id="address-field" cols="30" rows="3"
placeholder="Enter your address">Delhi</textarea>D. Fieldset aur Legend
<fieldset> related form controls ko group karta hai aur normally unke around border dikhata hai. Iska pehla <legend> group ka caption/title deta hai.
<form onsubmit="event.preventDefault()">
<fieldset>
<legend>Application form</legend>
<label>Name: <input type="text" name="name"></label><br>
<label>Email: <input type="email" name="email"></label>
</fieldset>
</form>| Attribute | Values / Example | Meaning |
|---|---|---|
| fieldset: disabled | Boolean: disabled | Group ke controls ko disable karta hai (first legend ke andar controls iska exception hain). |
| fieldset: name / form | "personalInfo" / "registration" | Group ka naam / associated form ki ID. |
| legend | <legend>Application form</legend> | Group heading element; iska separate value attribute nahi hota. |
E. Select aur Option: dropdown list
<select> selection list banata hai; andar ke <option> choices dete hain. Screen par option ka text aur submission mein uska value jaata hai.
| Attribute | Values / Example | Meaning |
|---|---|---|
| select: name / id | "language" / "language-list" | Submission key / associated label ID. |
| select: multiple / size | multiple / "4" | Multiple selections allow karna / visible option rows. |
| select: required / disabled | Boolean attributes | Selection validation / control disable karna. |
| option: value | "html" | "css" | "js" | "php" | Chosen option ka submitted value. Empty value placeholder ke liye useful hai. |
| option: selected / disabled | Boolean attributes | Initial selection / unselectable choice. |
<label for="language-list">Select your language:</label>
<select name="language" id="language-list" required>
<option value="" selected disabled>Select your language</option>
<option value="html">HTML</option>
<option value="css">CSS</option>
<option value="js">JavaScript</option>
<option value="php">PHP</option>
</select>F. Button: submit, reset aur normal action
<button>Log in</button> mein button label tags ke beech hota hai. Form ke andar missing type normally submit karta hai; accidental submission rokne ke liye normal actions par type="button" likhein.
| Attribute | Values / Example | Meaning |
|---|---|---|
| type | "submit" | "reset" | "button" | Form submit / defaults restore / normal button (behavior JS se). |
| name / value | "action" / "login" | Clicked submit button ka name/value data mein include ho sakta hai. Visible label button content hota hai. |
| disabled | Boolean: disabled | Button interaction disable karta hai. |
<form onsubmit="event.preventDefault(); document.getElementById('button-status').textContent = 'Demo submitted locally.';">
<input type="text" name="student" value="Student">
<button type="submit" name="action" value="login">Log in</button>
<button type="reset">Reset</button>
<button type="button" onclick="document.getElementById('button-status').textContent = 'Normal button clicked.';">Check</button>
<p id="button-status" role="status"></p>
</form>G. Complete Application Form — local practice
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Application Form Demo</title></head>
<body>
<h1>Student Application Form</h1>
<!-- Demo only: submission is stopped; no account is created or data uploaded. -->
<form id="registration" name="registrationForm" method="post" enctype="multipart/form-data"
onsubmit="event.preventDefault(); document.getElementById('form-result').textContent = 'Demo complete — no data was sent.';">
<fieldset>
<legend>Personal information</legend>
<label>First name: <input type="text" name="firstName" value="Student" required></label><br><br>
<label>Last name: <input type="text" name="lastName" required></label><br><br>
<label>Date of birth: <input type="date" name="dob"></label><br><br>
<label>Age: <input type="number" name="age" min="1" max="120"></label><br><br>
<label>Email: <input type="email" name="email" required></label><br><br>
<label>Phone: <input type="tel" name="phone"></label><br><br>
<label>Demo password: <input type="password" name="password" minlength="8" autocomplete="new-password"></label>
</fieldset>
<fieldset>
<legend>Learning preferences</legend>
<p>Favourite web language:</p>
<label><input type="radio" name="language" value="html" checked> HTML</label>
<label><input type="radio" name="language" value="css"> CSS</label>
<label><input type="radio" name="language" value="js"> JavaScript</label>
<p>Skills:</p>
<label><input type="checkbox" name="skills" value="software"> Software developer</label>
<label><input type="checkbox" name="skills" value="design"> Graphic designer</label><br><br>
<label>Course: <select name="course" required>
<option value="" selected disabled>Select a course</option>
<option value="html">HTML</option><option value="css">CSS</option>
<option value="js">JavaScript</option><option value="php">PHP</option>
</select></label><br><br>
<label>Meeting time: <input type="time" name="meetingTime"></label><br><br>
<label>Address:<br><textarea name="address" rows="3" cols="30" placeholder="Your address"></textarea></label><br><br>
<label>Document: <input type="file" name="document" accept=".pdf,image/*"></label><br><br>
<label>Color: <input type="color" name="color" value="#2563eb"></label>
<label>Level: <input type="range" name="level" min="1" max="10" value="5"></label>
</fieldset>
<input type="submit" value="Submit application">
<input type="reset" value="Reset">
<button type="button" onclick="document.getElementById('form-result').textContent = 'Fill the fields, then Submit.';">Help</button>
<p id="form-result" role="status"></p>
</form>
</body>
</html>Student wapas aayega. Radio group se sirf ek language aur checkboxes se dono skills select karke dekhein. Submit demo message dikhata hai; real login, file upload ya server save nahi karta.Reference: HTML Standard: forms and form controls.
Task 8: Student Registration Form
Ab aapne sabhi form elements seekh liye hain! Task 8 me complete Student Registration Form banayein jisme Personal Info, Account Info, Radio, Checkbox, Dropdown, aur Textarea ho.
<form><fieldset><legend><input type><select><textarea>submit22. <div> and <span> Tags
<div> is a block-level container. <span> is an inline container.
<!-- div - Block level -->
<div style="background:#eee; padding:20px; margin:10px 0;">
<h2 id="section-title">Section Title</h2>
<p>Content in a div.</p>
</div>
<!-- span - Inline -->
<p>My name is <span style="color:blue; font-weight:bold;">
Rahul</span> and I study <span style="color:orange;">
Computer Science</span>.</p>| Feature | <div> | <span> |
|---|---|---|
| Type | Block-level | Inline |
| Width | Full width | Content width |
| New Line | Yes | No |
| Use | Group sections | Style inline text |
<div> to group entire layout blocks and <span> to style specific words or phrases inline.23. HTML5 Semantic Elements
Semantic elements describe their meaning clearly, helping browsers and search engines understand page structure.
<header>
<nav>
<a href="/">Home</a> |
<a href="/about">About</a>
</nav>
</header>
<main>
<article>
<h1>Article Title</h1>
<p>Content...</p>
</article>
<section>
<h2 id="section-title">Section Title</h2>
</section>
<aside>
<h3 id="related-links">Related Links</h3>
</aside>
</main>
<footer>
<p>© 2025 Knobly Education</p>
</footer>Semantic Tags:
<header> — Page header<nav> — Navigation<main> — Main content<article> — Independent content<section> — Thematic group<aside> — Sidebar<footer> — Page footer<figure> — Image + captionTask 11: Premium Demo Website Layout
HTML5 semantic elements (<header>, <nav>, <footer>) aur structured tables ka use karke ek modern business demo website banayein.
<header><nav><footer><table><form><h1> - <h3>©24. Audio and Video Tags
HTML5 media: <audio> sound aur <video> moving pictures/sound embed karta hai. Dono container tags hain: closing tag zaroor likhein. Media file ka path direct src par ya child <source> par de sakte hain.
A. Audio tag — sound on a web page
MP3, Ogg aur WAV common formats hain. Browser support file format ke saath codec par bhi depend karta hai. <source> ek empty tag hai; multiple sources mein browser supported candidate choose karta hai.
<audio controls loop preload="metadata">
<source src="audio.mp3" type="audio/mpeg">
<source src="audio.ogg" type="audio/ogg">
Your browser does not support HTML audio.
<a href="audio.mp3">Download the audio</a>
</audio>
<!-- Alternative: one file directly on the audio element -->
<audio src="audio.mp3" controls></audio>| Attribute | Values / Example | Meaning |
|---|---|---|
| controls | Boolean: controls | Browser ke play/pause, seek, volume jaise controls show karta hai. |
| autoplay | Boolean: autoplay | Playback automatically start karne ki request. Browser policy, user interaction aur iframe permissions ke kaaran block ho sakti hai. |
| loop | Boolean: loop | Media finish hone par shuru se dobara play karta hai. |
| muted | Boolean: muted | Playback initially bina sound ke start hota hai. |
| src | "audio.mp3" | full media URL | Media file ka address; source children use karein to parent src omit karein. |
| preload | "none" | "metadata" | "auto" | Browser ko loading hint: pehle load na kare / duration jaisi info / zyada data buffer kar sakta hai. Yeh guarantee nahi hai. |
| source: type | "audio/mpeg" | "audio/ogg" | "audio/wav" | Source file ka MIME type; MP3 ke liye audio/mpeg. Yeh file convert nahi karta. |
controls="false" se controls off nahi hote: attribute present hone par on maana jaata hai. Off karne ke liye attribute hataayein. Yeh rule autoplay, loop aur muted par bhi apply hota hai.B. Video tag — size, poster and playback
MP4, WebM aur Ogg video containers hain. width aur height player ka display size dete hain; CSS se responsive size bhi set kar sakte hain. poster playback shuru hone se pehle image dikhata hai.
<video width="320" height="240" controls poster="thumbnail.jpg" preload="metadata">
<source src="video.mp4" type="video/mp4">
<source src="video.webm" type="video/webm">
Your browser does not support HTML video.
<a href="video.mp4">Download the video</a>
</video>
<!-- Autoplay is a request; muted inline video is more likely to be allowed. -->
<video src="video.mp4" width="320" height="240" autoplay muted loop playsinline></video>| Attribute | Values / Example | Meaning |
|---|---|---|
| controls / autoplay / loop / muted | Boolean attributes | Audio ki tarah controls, auto-start request, repeat aur initial mute. |
| src | "video.mp4" | Video file ka path ya direct media URL. |
| width / height | "320" / "240" | Player dimensions in CSS pixels. Responsive CSS example: width:100%; max-width:640px; height:auto. |
| poster | "thumbnail.jpg" | Video ka preview/cover image URL. Yeh sirf video ke liye hai. |
| preload | "none" | "metadata" | "auto" | Media loading hint, audio ki tarah. |
| playsinline | Boolean: playsinline | Mobile par video ko page ke player mein hi play karne ka hint. |
| source: type | "video/mp4" | "video/webm" | "video/ogg" | File/codec selection mein browser ki madad karta hai. |
C. Working media examples
Local examples ke liye actual audio/video files HTML ke saath save karein. Neeche runnable example public MDN CC0 sample URLs use karta hai; internet chahiye. Audio/video khud play karne ke liye Play dabayein.
<h2>Audio demo</h2>
<audio controls preload="none">
<source src="https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3" type="audio/mpeg">
Audio is not supported.
</audio>
<h2>Video demo</h2>
<video controls preload="none" playsinline width="320" height="240"
style="max-width:100%;height:auto;">
<source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4" type="video/mp4">
Video is not supported.
</video>D. Captions, fallback and troubleshooting
<video controls width="640" height="360">
<source src="lesson.mp4" type="video/mp4">
<track kind="captions" src="captions-en.vtt" srclang="en" label="English" default>
Your browser does not support video.
</video><track>captions/subtitles ke liye WebVTT file use karta hai. Cross-origin caption files ko appropriate CORS support chahiye.- Fallback text un browsers ke liye hai jo media element support nahi karte; modern browser mein missing file ki error par yeh text dikhna guaranteed nahi.
- File path, capitalization, MIME type, codec aur network connection check karein.
srcko YouTube watch-page URL na dein; iframe embedding agle chapters mein hai. - Autoplay na chale to controls se manual Play try karein.
mutedke saath bhi autoplay guaranteed nahi hai.
Reference: HTML Standard: audio, video and media attributes. Runnable sample media: MDN interactive examples (CC0).
Task 9: Solar System Basics (with Video Player)
Solar System page jisme detailed facts table ke sath embedded HTML5 video player (<video controls>) ho.
<video controls><source><table><ol><form><img>Task 5.4: The Wonders of Space
Space exploration multimedia page with facts table, celestial lists, aur astronomical links.
video/media<table><ul><ol><dl><img>25. HTML5 Form Validation
HTML5 validation browser ko form submit hone se pehle input rules check karne deta hai. Invalid field par browser message dikhata hai aur normal submission rok deta hai. Is chapter ke demos valid hone par bhi event.preventDefault() use karte hain: input kahin send nahi hota.
A. Required attribute
required ek Boolean attribute hai. Applicable field empty ho to browser normal form submission rokta hai. required="false" bhi present attribute hai; optional banane ke liye attribute remove karein.
<form onsubmit="event.preventDefault(); document.getElementById('required-result').textContent = 'Valid demo: no data sent.';">
<label>Enter your name: <input type="text" name="student" required></label>
<input type="submit" value="Check name">
<p id="required-result" role="status"></p>
</form>B. Pattern attribute — allowed text and length
pattern ek regular expression hai jo poori input value se match hota hai. Yeh text, search, url, tel, email aur password par apply hota hai; number par nahi. Empty optional field pattern se reject nahi hoti; blank bhi rokna ho to required lagayein.
| Attribute | Values / Example | Meaning |
|---|---|---|
| [A-Za-z] | One English letter | Uppercase A–Z ya lowercase a–z. Character class ke andar comma mat add karein; comma bhi allowed character ban jaayega. |
| [0-9] | One digit | 0 se 9 tak ek digit. |
| {1,5} / {10} | 1–5 repetitions / exactly 10 | Braces min/max count define karte hain; {10} ka matlab maximum 10 nahi, exactly 10 hai. |
| + | One or more | Kam se kam ek character; regex mein fixed upper count nahi. |
| title | "Use 1 to 5 digits" | Browser ko extra format hint; exact validation message/browser language vary kar sakti hai. Visible help text bhi dein. |
Modern HTML patterns Unicode v mode use karte hain. Character class mein literal hyphen ko \- likhein. Neeche handwritten patterns ki intent ko correct syntax aur correct total lengths ke saath diya gaya hai.
1. Only alphabets, maximum 5 characters
Pattern
pattern="[A-Za-z]{1,5}"Valid: Hello · Invalid: Hello1
<form onsubmit="event.preventDefault(); document.getElementById('pattern-result').textContent = 'Pattern matched: no data sent.';">
<label for="pattern-input">Only alphabets, maximum 5 characters</label>
<p id="pattern-help">Use 1 to 5 English letters.</p>
<input id="pattern-input" name="practice" type="text" required
pattern="[A-Za-z]{1,5}" title="Use 1 to 5 English letters." aria-describedby="pattern-help">
<button type="submit">Check pattern</button>
<p id="pattern-result" role="status"></p>
</form>2. Letters or digits, minimum 1 character
Pattern
pattern="[A-Za-z0-9]+"Valid: HTML5 · Invalid: HTML 5
<form onsubmit="event.preventDefault(); document.getElementById('pattern-result').textContent = 'Pattern matched: no data sent.';">
<label for="pattern-input">Letters or digits, minimum 1 character</label>
<p id="pattern-help">Use one or more English letters or digits; no spaces.</p>
<input id="pattern-input" name="practice" type="text" required
pattern="[A-Za-z0-9]+" title="Use one or more English letters or digits; no spaces." aria-describedby="pattern-help">
<button type="submit">Check pattern</button>
<p id="pattern-result" role="status"></p>
</form>3. Only numbers, maximum 10 digits
Pattern
pattern="[0-9]{1,10}"Valid: 12345 · Invalid: 12345678901
<form onsubmit="event.preventDefault(); document.getElementById('pattern-result').textContent = 'Pattern matched: no data sent.';">
<label for="pattern-input">Only numbers, maximum 10 digits</label>
<p id="pattern-help">Use 1 to 10 digits. This accepts leading zeros.</p>
<input id="pattern-input" name="practice" type="text" required
pattern="[0-9]{1,10}" title="Use 1 to 10 digits. This accepts leading zeros." aria-describedby="pattern-help">
<button type="submit">Check pattern</button>
<p id="pattern-result" role="status"></p>
</form>4. Exactly 10 digits
Pattern
pattern="[0-9]{10}"Valid: 0123456789 · Invalid: 12345
<form onsubmit="event.preventDefault(); document.getElementById('pattern-result').textContent = 'Pattern matched: no data sent.';">
<label for="pattern-input">Exactly 10 digits</label>
<p id="pattern-help">Use exactly 10 digits. This is a length rule, not phone-number ownership verification.</p>
<input id="pattern-input" name="practice" type="text" required
pattern="[0-9]{10}" title="Use exactly 10 digits. This is a length rule, not phone-number ownership verification." aria-describedby="pattern-help">
<button type="submit">Check pattern</button>
<p id="pattern-result" role="status"></p>
</form>5. Alphabets with no fixed upper count
Pattern
pattern="[A-Za-z]+"Valid: LearningHTML · Invalid: HTML5
<form onsubmit="event.preventDefault(); document.getElementById('pattern-result').textContent = 'Pattern matched: no data sent.';">
<label for="pattern-input">Alphabets with no fixed upper count</label>
<p id="pattern-help">Use one or more English letters. No fixed maximum is set by this pattern.</p>
<input id="pattern-input" name="practice" type="text" required
pattern="[A-Za-z]+" title="Use one or more English letters. No fixed maximum is set by this pattern." aria-describedby="pattern-help">
<button type="submit">Check pattern</button>
<p id="pattern-result" role="status"></p>
</form>6. Letters, numbers, underscore, @ and hyphen
Pattern
pattern="[A-Za-z0-9_@\-]+"Valid: student_1@web-site · Invalid: student!
<form onsubmit="event.preventDefault(); document.getElementById('pattern-result').textContent = 'Pattern matched: no data sent.';">
<label for="pattern-input">Letters, numbers, underscore, @ and hyphen</label>
<p id="pattern-help">Use letters, digits, underscore, @ or hyphen; no spaces.</p>
<input id="pattern-input" name="practice" type="text" required
pattern="[A-Za-z0-9_@\-]+" title="Use letters, digits, underscore, @ or hyphen; no spaces." aria-describedby="pattern-help">
<button type="submit">Check pattern</button>
<p id="pattern-result" role="status"></p>
</form>7. Username: first letter, total 1–25 characters
Pattern
pattern="[A-Za-z][A-Za-z0-9_\-]{0,24}"Valid: Student_1 · Invalid: 1Student
<form onsubmit="event.preventDefault(); document.getElementById('pattern-result').textContent = 'Pattern matched: no data sent.';">
<label for="pattern-input">Username: first letter, total 1–25 characters</label>
<p id="pattern-help">Start with an English letter; then use letters, digits, underscore or hyphen. Total length: 1 to 25.</p>
<input id="pattern-input" name="practice" type="text" required
pattern="[A-Za-z][A-Za-z0-9_\-]{0,24}" title="Start with an English letter; then use letters, digits, underscore or hyphen. Total length: 1 to 25." aria-describedby="pattern-help">
<button type="submit">Check pattern</button>
<p id="pattern-result" role="status"></p>
</form>Username pattern mein pehla [A-Za-z] already ek character hai. Uske baad {0,24} se total 1–25 characters bante hain; {1,25} likhne par total 2–26 ho jaate.
C. Title and Autofocus
Pattern
pattern="[0-9]{1,5}"title format ka extra hint hai. autofocus page/dialog load par field ko focus dene ki request karta hai; value validate nahi karta. Ek document mein sirf ek intended autofocus target rakhein. Guide khud focus nahi badalta; Run example kholne par try karein.
<form onsubmit="event.preventDefault(); document.getElementById('focus-result').textContent = 'Valid: no data sent.';">
<label for="digits">Enter 1 to 5 digits:</label>
<input id="digits" name="digits" type="text" required autofocus
pattern="[0-9]{1,5}" title="Only 1 to 5 digits are allowed">
<input type="submit" value="Validate">
<p id="focus-result" role="status"></p>
</form>D. Email and multiple email addresses
type="email" browser se address syntax check karwata hai. multiple lagane par comma-separated addresses allowed hain. Isse inbox exist/own karna verify nahi hota; built-in browser syntax aur real email verification alag cheezein hain.
<form onsubmit="event.preventDefault(); document.getElementById('email-result').textContent = 'Email syntax is valid; no email was sent.';">
<label for="emails">Email addresses (separate with commas):</label>
<input id="emails" type="email" name="emails" multiple required
placeholder="first@example.com, second@example.com">
<button type="submit">Check emails</button>
<p id="email-result" role="status"></p>
</form>E. Number: min, max and step
min lower limit, max upper limit aur step valid increment define karte hain. Number ka default step 1 hai; decimals ke liye step="0.1" ya step="any" use karein. pattern aur maxlength ki jagah number ke numeric rules use karein.
<form onsubmit="event.preventDefault(); document.getElementById('number-result').textContent = 'Quantity is valid: no data sent.';">
<label>Enter quantity (1 to 10, steps of 0.1):
<input type="number" name="quantity" min="1" max="10" step="0.1" required>
</label>
<input type="submit" value="Check quantity">
<p id="number-result" role="status"></p>
</form>1.5 (valid), 0.9 / 10.1 (outside bounds), aur 1.55 (step mismatch). Valid steps min=1 se count hote hain.F. Date: calendar input with limits
type="date" date picker de sakta hai; display locale/browser par depend karta hai. HTML value, min aur max ka format YYYY-MM-DD hota hai.
<form onsubmit="event.preventDefault(); document.getElementById('date-result').textContent = 'Date is in the sample year: no data sent.';">
<label>Choose a date in 2026:
<input type="date" name="practiceDate" min="2026-01-01" max="2026-12-31" required>
</label>
<button type="submit">Check date</button>
<p id="date-result" role="status"></p>
</form>G. Range: slider, limits and steps
type="range" slider deta hai. Limits omit karne par default range 0–100 aur step 1 hai. Iska value browser bounds/step ke mutabik adjust karta hai; required range par apply nahi hota, kyunki slider ka default value hota hai.
<form onsubmit="event.preventDefault(); document.getElementById('range-result').textContent = 'Range selected locally: ' + this.elements.level.value;">
<label for="level">Select range (1 to 50, steps of 2):</label>
<input id="level" type="range" name="level" min="1" max="50" step="2" value="1"
oninput="document.getElementById('range-value').textContent = this.value;">
<output id="range-value" for="level">1</output>
<button type="submit">Show selection</button>
<p id="range-result" role="status"></p>
</form>Yahan min=1 aur step=2 se values 1, 3, 5, …, 49 hoti hain. Max=50 upper bound hai; 50 step sequence mein nahi aata.
H. Validation summary and testing
| Attribute | Values / Example | Meaning |
|---|---|---|
| required | Boolean | Supported control empty ho to normal submission block. |
| pattern / title | Regex / readable format hint | Text format rules aur helpful instructions. |
| minlength / maxlength | "3" / "25" | Supported text controls ki length rules; minlength user edits par check hota hai aur optional empty input ko required nahi banata. |
| min / max / step | "1" / "10" / "0.1" | Applicable numeric/date/time controls ki limits aur valid steps. |
| type="email" / multiple | Email syntax / comma-separated list | Browser address format validation; delivery/ownership verification nahi. |
| autofocus | Boolean | Focus behavior, validation rule nahi. |
| novalidate / formnovalidate | Boolean | Form / specific submit button se native submit validation bypass kar sakte hain. |
requestSubmit() validation chalata hai. JavaScript form.submit() validation bypass karta hai. Real application mein browser checks ke saath backend par bhi validation zaroor karein. In practice snippets mein koi backend call nahi hoti.Reference: HTML Standard: input types, pattern and constraints.
26. <iframe> Tag
The <iframe> tag embeds another HTML page within the current page.
<!-- Embed a webpage -->
<iframe src="https://www.example.com"
width="600" height="400"></iframe>
<!-- Embed Google Maps -->
<iframe src="https://www.google.com/maps/embed?pb=..."
width="600" height="450"
style="border:0;" allowfullscreen
loading="lazy"></iframe>
<!-- Link targeting iframe -->
<iframe src="page.html" name="myframe"
width="100%" height="500"></iframe>
<a href="page2.html" target="myframe">Load Page 2</a>target="myframe" on an anchor tag to open links directly inside an embedded iframe!YouTube video embed
YouTube watch-page URL ko <video src> mein na dein. Share → Embed se iframe URL lein; neeche VIDEO_ID ko actual video ID se replace karein.
<iframe width="560" height="315"
src="https://www.youtube.com/embed/VIDEO_ID"
title="YouTube lesson video"
allowfullscreen></iframe>27. HTML Entities & Capstone Project
Reserved characters in HTML must be displayed using entities.
| Char | Entity | Code | Description |
|---|---|---|---|
| < | < | < | Less than |
| > | > | > | Greater than |
| & | & | & | Ampersand |
| " | " | " | Double quote |
|   | Non-breaking space | |
| © | © | © | Copyright |
| ® | ® | ® | Registered |
| ™ | ™ | ™ | Trademark |
| ₹ | ₹ | ₹ | Rupee |
| ♥ | ♥ | ♥ | Heart |
| → | → | → | Right arrow |
| ★ | ★ | ★ | Star |
<p>5 < 10 and 10 > 5</p>
<p>Price: ₹500</p>
<p>© 2025 Knobly Education</p>
<p>I ♥ HTML</p>Task 10: Full Multi-Section Website Layout (Capstone Project)
Badhaai ho! Ab aapne HTML ke sabhi chapters complete kar liye hain! Task 10 me nav, marquee, tables, forms, videos, lists, aur iframes ko mila kar ek complete master website banayein.
<iframe><video><nav><table><form><dl><ul>©
8. HTML Comment Tag
HTML comments are used to add notes, explanations, or reminders in the source code. Comments are not displayed in the browser — they are only visible in the source code.
Comment Uses:
⚠️ Important Rules:
<!--and end with--><body>tag explaining the purpose of your page. Example:<!-- My Profile Page - Created for O-Level Practice -->