HTML Web Basics Complete Lecture Notes
HTML Web Basics Complete Lecture Notes
COMPREHENSIVE LECTURE
NOTES
(25 Pages)
1. What is Internet
2. Web Browsers
3. What is Webpage
4. HTML Basics
5. Understanding Tags
6. Key Concepts & Applications
7. Questions (5 Mark & 10 Mark)
1. WHAT IS INTERNET?
Characteristic Description
—2—
- Created HTTP and HTML
┌─────────────────────────────────────────────────┐
│ INTERNET │
├─────────────────────────────────────────────────┤
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
│ │ Regional │ │ Regional │ │ Regional │ │
│ │ Networks │ │ Networks │ │ Networks │ │
│ └──────┬─────┘ └──────┬─────┘ └──────┬─────┘ │
│ │ │ │ │
│ ┌──────────────────────────────────────────┐ │
│ │ Internet Exchange Point (IXP) │ │
│ └──────────────────────────────────────────┘ │
│ │ │ │ │
│ ┌──────┴─────┐ ┌──────┴─────┐ ┌──────┴─────┐ │
│ │ ISP 1 │ │ ISP 2 │ │ ISP 3 │ │
│ └──────┬─────┘ └──────┬─────┘ └──────┬─────┘ │
│ │ │ │ │
│ ┌────┴────┬───────┬───┴────┬───────┬──┴────┐ │
│ │ │ │ │ │ │ │
│ PC Router Server Mobile Laptop Cloud│
│ │
└─────────────────────────────────────────────────┘
—3—
Step 1: User enters URL in browser
└─> "[Link]"
2. WEB BROWSERS
—4—
2.2 Major Web Browsers
┌─────────────────────────────────────────┐
│ WEB BROWSER FUNCTIONS │
├─────────────────────────────────────────┤
│ │
│ 1. Retrieve Web Resources │
│ └─> Downloads HTML, CSS, JS, etc. │
│ │
│ 2. Parse HTML Documents │
│ └─> Reads HTML tags │
│ │
│ 3. Render Content │
│ └─> Displays visual webpage │
│ │
│ 4. Execute Scripts │
│ └─> Runs JavaScript code │
│ │
│ 5. Display Multimedia │
│ └─> Shows images, video, audio │
│ │
│ 6. Store Data │
│ └─> Cookies, LocalStorage │
│ │
│ 7. Provide User Interaction │
│ └─> Forms, Links, Buttons │
—5—
│ │
└─────────────────────────────────────────┘
┌────────────────────────────────┐
│ User enters URL │
└────────────┬───────────────────┘
│
▼
┌────────────────────────────────┐
│ DNS Lookup (Get IP address) │
└────────────┬───────────────────┘
│
▼
┌────────────────────────────────┐
│ HTTP Request sent to server │
└────────────┬───────────────────┘
│
▼
┌────────────────────────────────┐
│ Server sends HTML response │
└────────────┬───────────────────┘
│
▼
┌────────────────────────────────┐
│ Browser parses HTML │
└────────────┬───────────────────┘
│
▼
┌────────────────────────────────┐
│ Fetch CSS files & parse │
└────────────┬───────────────────┘
│
▼
┌────────────────────────────────┐
│ Fetch JavaScript files │
└────────────┬───────────────────┘
│
—6—
▼
┌────────────────────────────────┐
│ Render layout (Reflow) │
└────────────┬───────────────────┘
│
▼
┌────────────────────────────────┐
│ Paint pixels (Repaint) │
└────────────┬───────────────────┘
│
▼
┌────────────────────────────────┐
│ Display webpage to user │
└────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│ User Interface (Address bar, Toolbar, Menu) │
├─────────────────────────────────────────────────────────┤
│ Rendering Engine (Interprets HTML, CSS) │
├─────────────────────────────────────────────────────────┤
│ JavaScript Engine (Executes JS code) │
├─────────────────────────────────────────────────────────┤
│ Networking Layer (Handles HTTP requests) │
├─────────────────────────────────────────────────────────┤
│ Storage (Cookies, LocalStorage, IndexedDB) │
├─────────────────────────────────────────────────────────┤
│ DOM (Document Object Model) │
└─────────────────────────────────────────────────────────┘
—7—
3. WHAT IS A WEBPAGE?
3.1 Definition
A webpage is a document written in HTML (HyperText Markup Language) that is
retrieved from a web server and displayed in a web browser. It can contain text, images,
videos, hyperlinks, forms, and interactive elements.
┌──────────────────────────────────┐
│ STATIC WEBPAGES │
├──────────────────────────────────┤
│ • Same content for all users │
│ • Pre-built HTML files │
│ • Fast loading │
│ • Limited interactivity │
│ • Example: Blog post, About page │
│ │
│ Server ──────> HTML ──────> User │
└──────────────────────────────────┘
┌──────────────────────────────────┐
│ DYNAMIC WEBPAGES │
├──────────────────────────────────┤
│ • Content changes based on user │
—8—
│ • Generated on-the-fly │
│ • Uses databases & backend code │
│ • More interactive │
│ • Example: Gmail, Facebook │
│ │
│ User ──────> Request ──────> DB │
│ └──> Server generates│
│ HTML ──────> User│
└──────────────────────────────────┘
┌─────────────────────────────────────────────┐
│ HEADER / NAVIGATION │
│ Logo Menu Items Search │
├─────────────────────────────────────────────┤
│ │
│ MAIN CONTENT AREA │
│ │
│ ┌─────────────────────────────────────┐ │
│ │ Article / Page Content │ │
│ │ │ │
│ │ Lorem ipsum dolor sit amet... │ │
│ │ │ │
│ └─────────────────────────────────────┘ │
│ │
├─────────────────────────────────────────────┤
│ SIDEBAR (Optional) │
│ • Related Articles │
│ • Advertisements │
│ • Categories │
├─────────────────────────────────────────────┤
│ FOOTER │
│ Copyright © 2024 | Privacy | Contact Us │
└─────────────────────────────────────────────┘
—9—
3. Product Pages - E-commerce item details
4. Contact Pages - Communication channels
5. FAQ Pages - Common questions
6. Portfolio Pages - Showcase of work
7. Service Pages - Description of services
8. News Pages - Latest updates
4. HTML BASICS
Aspect Details
Benefits of HTML:
— 10 —
✓ Combines well with CSS and JavaScript
✓ SEO friendly
✓ Flexible and extensible
✓ Free to use
<!DOCTYPE html>
<html>
<head>
<title>My First Webpage</title>
</head>
<body>
<h1>Welcome to HTML</h1>
<p>This is a paragraph.</p>
</body>
</html>
Output:
┌─────────────────────────────────┐
│ My First Webpage (Tab Title) │
├─────────────────────────────────┤
— 11 —
│ │
│ Welcome to HTML │
│ │
│ This is a paragraph. │
│ │
└─────────────────────────────────┘
┌────────────────────────────────────┐
│ <!DOCTYPE html> │
│ Declaration - HTML5 version │
├────────────────────────────────────┤
│ <html> │
│ Contains entire webpage │
│ ├─ <head> │
│ │ Metadata & resources │
│ │ (Not visible to user) │
│ │ │
│ └─ <body> │
│ Visible content │
│ (Seen by user) │
│ </html> │
└────────────────────────────────────┘
5. UNDERSTANDING TAGS
— 12 —
5.2 Tag Structure
<p>This is a paragraph</p>
<h1>This is a heading</h1>
<div>This is a division</div>
2. Empty Tags (Self-closing Tags) - No closing tag needed - Content ends within the
tag
Syntax:
<tag attribute="value">Content</tag>
Example:
— 13 —
<img src="[Link]" alt="My Photo" width="200">
│ │ │
Attribute Attribute Attribute
— 14 —
<!-- Output (Correct): -->
This is correct nesting.
┌──────────────────────────────────────────────────┐
│ WEB TECHNOLOGY STACK │
├──────────────────────────────────────────────────┤
│ │
│ CLIENT SIDE (Browser) │
│ ├─ HTML (Structure) │
│ ├─ CSS (Styling) │
│ └─ JavaScript (Interactivity) │
│ │
│ ──────────────────────────────────────────── │
│ HTTP Protocol │
│ ──────────────────────────────────────────── │
│ │
│ SERVER SIDE │
│ ├─ Backend Language (PHP, Python, [Link]) │
│ ├─ Database (MySQL, MongoDB) │
│ └─ Business Logic │
│ │
└──────────────────────────────────────────────────┘
— 15 —
6.2 HTTP Protocol Basics
Aspect Description
— 16 —
7. IMPORTANT QUESTIONS
A web browser is software that retrieves and displays webpages from the Internet. When
a user enters a URL, the browser sends an HTTP request to the web server. The server
responds with HTML, CSS, and JavaScript files. The browser’s rendering engine parses
this code and converts it into visual content. Browsers include components like
JavaScript engines for running scripts, networking modules for communication, and
storage systems for caching. Popular browsers include Chrome, Firefox, Safari, and Edge.
Each browser interprets web standards slightly differently, requiring developers to test
across browsers. Browsers also handle security, cookies, bookmarks, and provide
developer tools for debugging web applications.
HTML (HyperText Markup Language) is the fundamental markup language for creating
webpages. Created by Tim Berners-Lee in 1989, HTML uses tags and elements to
structure web content. It’s essential because it provides the semantic structure that web
browsers need to render webpages. HTML separates content from presentation by
working alongside CSS for styling and JavaScript for interactivity. It’s platform-
independent, easy to learn, and supported by all browsers. HTML5, the current standard,
includes semantic elements, multimedia support, and APIs. HTML forms the foundation
upon which all modern web technologies are built, making it indispensable for web
development.
— 17 —
A basic HTML document follows a specific structure: <!DOCTYPE html> declares the
document version, is the root element, contains metadata like title and links to
stylesheets, and contains visible content. Example:
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>Hello World</h1>
<p>Welcome!</p>
</body>
</html>
The head section is invisible to users but provides important information. The body
contains elements like headings, paragraphs, images, and links. Proper structure
ensures browser compatibility and SEO optimization.
Q5. What are HTML tags and attributes? Explain with examples.
HTML tags are keywords in angle brackets that define elements and tell browsers how to
display content. They come in two types: container tags with opening and closing tags
(like <p>...</p> ), and empty/self-closing tags (like <br> or <img> ). Attributes provide
additional information about elements and are placed in opening tags. Syntax: <tag
attribute="value">content</tag> . Example: <img src="[Link]" alt="My Photo"
width="200"> . Here, src, alt, and width are attributes. Common attributes include src,
href, class, id, style, and onclick. Attributes modify how elements behave and appear,
enabling developers to add metadata, links, dimensions, and event handlers to HTML
elements.
The Internet works through a complex system of interconnected networks and protocols.
When a user enters a URL in the browser’s address bar, the following sequence occurs:
— 18 —
Request Phase: 1. Browser sends request to Internet Service Provider (ISP) 2. ISP
routes request through backbone networks 3. Request reaches DNS (Domain Name
System) server 4. DNS translates domain name to IP address 5. Request finds web
server with that IP address
Processing Phase: 6. Web server receives HTTP request 7. Server processes the
request and retrieves requested files 8. Server compiles HTML, CSS, JavaScript
responses
Response Phase: 9. Server sends response back through Internet 10. Data travels
through multiple routers 11. Browser receives response packets
Rendering Phase: 12. Browser’s rendering engine parses HTML 13. CSS stylesheet is
applied for styling 14. JavaScript code is executed for interactivity 15. Browser
constructs DOM (Document Object Model) 16. Layout engine calculates positions
(Reflow) 17. Pixels are drawn to screen (Repaint) 18. User sees complete webpage
Diagram:
User ──> Browser ──> ISP ──> DNS ──> Web Server
│
└──> IP: [Link]
This entire process takes 100-500 milliseconds. Modern browsers optimize this through
caching, parallel downloads, and compression. DNS caching stores IP addresses locally
to avoid repeated lookups. Browsers download multiple resources simultaneously.
Images and styles are often compressed to reduce bandwidth usage.
Q2. Compare and contrast static and dynamic webpages with real-world
examples.
— 19 —
Aspect Static Webpages Dynamic Webpages
Static Webpages: - Simple HTML files stored on server - Same content delivered to
every visitor - Viewed with: File System or simple HTTP server - Best for: Company
information, portfolio sites - Example: About Us page with company description
Q3. Explain the roles of HTML, CSS, and JavaScript in web development.
HTML (Structure): - Provides semantic structure and content - Uses tags and elements
for organization - Creates meaningful document outline - Example: <header> ,
<article> , <footer>
CSS (Styling): - Controls visual presentation and layout - Handles colors, fonts, spacing,
positioning - Enables responsive design for different devices - Separates content from
presentation - Example: body { background-color: blue; }
Collaboration:
— 20 —
HTML: Content
↓
CSS: Appearance
↓
JavaScript: Behavior
↓
Complete Interactive Webpage
Together, these technologies create modern web applications. HTML provides the
foundation, CSS makes it look good, and JavaScript makes it interactive. Understanding
all three is essential for web development.
(25 Pages)
— 21 —
1. HTML HEAD SECTION
<!DOCTYPE html>
<html>
<head>
<!-- All metadata goes here -->
<title>Page Title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="[Link]">
<script src="[Link]"></script>
</head>
<body>
<!-- Visible content -->
</body>
</html>
A. Title Tag
<title>Welcome to My Website</title>
— 22 —
B. Meta Tags
C. Link Tag
D. Style Tag
— 23 —
E. Script Tag
<!DOCTYPE html>
<html>
<head>
<title>College Admission Portal</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Official college admission portal">
<meta name="keywords" content="college, admission, application">
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<!-- Page content -->
</body>
</html>
— 24 —
2. HTML BODY SECTION
<body>
<!-- Header with navigation -->
<header>
<h1>Website Title</h1>
<nav>
<ul>
<li><a href="[Link]">Home</a></li>
<li><a href="[Link]">About</a></li>
<li><a href="[Link]">Contact</a></li>
</ul>
</nav>
</header>
— 25 —
</footer>
</body>
<!DOCTYPE html>
<html>
<head>
<title>College Website</title>
</head>
<body>
<header>
<img src="[Link]" alt="College Logo">
<h1>ABC College</h1>
</header>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#programs">Programs</a></li>
<li><a href="#faculty">Faculty</a></li>
— 26 —
</ul>
</nav>
<main>
<article>
<h2>Welcome to ABC College</h2>
<p>Founded in 1995...</p>
</article>
</main>
<aside>
<h3>Quick Links</h3>
<ul>
<li><a href="[Link]">Admissions</a></li>
<li><a href="[Link]">Courses</a></li>
</ul>
</aside>
<footer>
<p>© 2024 ABC College. All rights reserved.</p>
</footer>
</body>
</html>
3. HEADING ELEMENTS
— 27 —
↓
<h3> - Sub-subheading
↓
<h4> - Fourth level heading
↓
<h5> - Fifth level heading
↓
<h6> - Minor heading (Smallest, Least Important)
Output:
<h2>Courses</h2>
<h3>Semester 1</h3>
<p>Course details...</p>
— 28 —
<h2>Faculty</h2>
<p>Faculty list...</p>
<h1>Computer Science</h1>
<h3>Jump from H1 to H3 - Bad!</h3>
<h6>Jump to H6 - Very Bad!</h6>
Document Outline:
1. H1: Homepage
1.1 H2: Welcome Section
1.2 H2: Services
1.2.1 H3: Service A
1.2.2 H3: Service B
1.3 H2: About Us
1.4 H2: Contact
Output:
— 29 —
This is another paragraph.
<p>
This is a longer paragraph that contains
multiple lines of text. The text will wrap
automatically based on the browser window
width and screen size.
</p>
Output:
<pre>
This text has
specific spacing
and line breaks
that will be preserved
</pre>
Output:
— 30 —
4.4 Line Breaks and Horizontal Rules
<hr>
Output:
First line
Second line
Third line
_________________________________
— 31 —
Tag Purpose Example
Both appear bold visually, but <strong> indicates importance to screen readers.
Italic vs Emphasized:
<!DOCTYPE html>
<html>
<head>
<title>Text Formatting</title>
</head>
<body>
— 32 —
<p><b>Bold text</b> using b tag</p>
<p><strong>Strong text</strong> using strong tag</p>
<p><i>Italic text</i> using i tag</p>
<p><em>Emphasized text</em> using em tag</p>
<p><small>Small text</small> using small tag</p>
<p><mark>Marked/highlighted text</mark></p>
<p><u>Underlined text</u></p>
<p><s>Strikethrough text</s></p>
</body>
</html>
Output:
Code example: x = 10
— 33 —
Colored text
</font>
<p>
This is <b><i>bold and italic</i></b> text.
</p>
<p>
This is <strong><mark>important and highlighted</mark></strong> text.
</p>
<p>
Chemical formula of water: H<sub>2</sub>O
</p>
<p>
The original price was <s>$100</s> now <strong>$50</strong>
</p>
Output:
— 34 —
6. KEY CONCEPTS & APPLICATIONS
1. <html>
1.1 <head>
• <title>
• <meta>
• <link>
• <style>
1.2 <body>
• <header>
• <nav>
• <main>
• <article>
• <section>
• <aside>
• <footer>
<!DOCTYPE html>
<html>
<head>
<title>Data Structures Course - ABC College</title>
<meta charset="UTF-8">
<meta name="description" content="Data Structures course materials">
</head>
<body>
<header>
<h1>ABC College</h1>
<p>Department of Computer Science</p>
</header>
— 35 —
<nav>
<a href="[Link]">Home</a> |
<a href="[Link]">Courses</a> |
<a href="[Link]">Faculty</a>
</nav>
<main>
<article>
<h1>Data Structures (CS-202)</h1>
<section>
<h2>Course Description</h2>
<p>
This course introduces fundamental data structures including
<strong>arrays, linked lists, stacks, queues, and trees</strong>.
</p>
</section>
<section>
<h2>Course Objectives</h2>
<p><strong>Upon completion, students will:</strong></p>
<ul>
<li>Understand data structure concepts</li>
<li>Implement various data structures</li>
<li>Analyze algorithm complexity</li>
</ul>
</section>
<section>
<h2>Course Content</h2>
<h3>Module 1: Arrays and Lists</h3>
<p>Introduction to <em>arrays</em> and <em>linked lists</em>...</p>
<section>
<h2>Grading Policy</h2>
<p>Attendance: <small>10%</small></p>
<p>Assignments: <small>20%</small></p>
<p>Mid Term: <small>25%</small></p>
— 36 —
<p>Final Exam: <small>45%</small></p>
</section>
</article>
</main>
<aside>
<h3>Important Dates</h3>
<p><strong>Midterm:</strong> September 15</p>
<p><strong>Final Exam:</strong> December 10</p>
</aside>
<footer>
<p>© 2024 ABC College. All rights reserved.</p>
</footer>
</body>
</html>
7. IMPORTANT QUESTIONS
5-MARK QUESTIONS
Q1. Explain the purpose of the head section and list important head elements.
The head section contains metadata and configuration information about the webpage
that is not displayed to users but is crucial for proper rendering and SEO. Important head
elements include: (1) <title> - appears in browser tab and used by search engines, (2)
<meta> - provides character encoding, viewport settings, and page description, (3)
<link> - links external stylesheets and favicon, (4) <style> - contains internal CSS
styling, (5) <script> - includes JavaScript code or external scripts. These elements
configure how browsers interpret and display the webpage, set character encoding to
support multiple languages, enable responsive design through viewport meta tags, and
improve SEO by providing descriptive information to search engines.
Q2. Differentiate between heading tags and explain proper heading hierarchy.
— 37 —
Heading tags <h1> through <h6> create titles and subtitles in decreasing order of
importance. H1 is the largest and most important, typically used for main page title. H2-
H6 create progressively smaller subheadings for organizing content sections. Proper
hierarchy means not skipping levels - if using H1, the next level should be H2, not H4.
This structure helps screen readers, search engines, and creates a logical outline. Each
page should have only one H1. Using correct hierarchy improves accessibility and SEO.
For example: H1 for page title, H2 for main sections, H3 for subsections within those
sections.
Q3. Compare bold and strong tags, and italic and em tags.
Bold ( <b> ) and strong ( <strong> ) both display text as bold, but strong carries semantic
meaning of importance. Similarly, italic ( <i> ) and emphasized ( <em> ) both display
slanted text, but em indicates emphasis in meaning. Screen readers treat these
differently: strong emphasis receives special attention, while bold is just visual. For
content marking: use <strong> for important information like warnings, and <b> for
stylistic boldness like highlighting keywords in a summary. Use <em> for stressed words
needing emphasis, and <i> for titles, foreign words, or technical terms. This distinction
matters for accessibility and search engine optimization.
Q4. What are semantic HTML5 elements and why are they important?
— 38 —
changes. Small reduces text for fine print. Using appropriate tags improves readability
and accessibility. For example: “Price was $100, now $50” clearly shows the price
reduction.
10-MARK QUESTIONS
Q1. Design a complete college homepage structure using semantic HTML5
elements. Include all major sections.
<!DOCTYPE html>
<html>
<head>
<title>XYZ College - Excellence in Education</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Leading institution for higher education">
</head>
<body>
<header>
<img src="[Link]" alt="College Logo">
<h1>XYZ College</h1>
<p><em>Excellence in Education Since 1995</em></p>
</header>
<nav>
<ul>
<li><a href="[Link]"><strong>Home</strong></a></li>
<li><a href="[Link]">About Us</a></li>
<li><a href="[Link]">Departments</a></li>
<li><a href="[Link]">Admissions</a></li>
<li><a href="[Link]">Contact</a></li>
</ul>
</nav>
<main>
<section>
<h2>Welcome to XYZ College</h2>
<p>
— 39 —
<strong>XYZ College</strong> is a premier institution dedicated to providing
<em>quality education</em> and developing future leaders in various fields.
</p>
</section>
<section>
<h2>Our Departments</h2>
<article>
<h3>Computer Science</h3>
<p>
Offering <strong>world-class</strong> education in programming,
<mark>data structures</mark>, databases, and web development.
</p>
</article>
<article>
<h3>Engineering</h3>
<p>
Comprehensive curriculum covering civil, mechanical, and electrical engineering
with hands-on laboratory experience.
</p>
</article>
<article>
<h3>Business Administration</h3>
<p>
Programs focused on developing business acumen and entrepreneurial skills.
</p>
</article>
</section>
<section>
<h2>Highlights</h2>
<ul>
<li><strong>100+</strong> Faculty Members</li>
<li><strong>5000+</strong> Students</li>
<li><strong>50+</strong> Academic Programs</li>
<li><strong>15+</strong> Research Centers</li>
</ul>
</section>
</main>
— 40 —
<aside>
<h3>Quick Links</h3>
<ul>
<li><a href="[Link]">Online Admission</a></li>
<li><a href="[Link]">Academic Calendar</a></li>
<li><a href="[Link]">Latest News</a></li>
</ul>
<h3>Important Dates</h3>
<p><strong>Admission Deadline:</strong> June 30</p>
<p><strong>Classes Start:</strong> July 15</p>
</aside>
<footer>
<p>© 2024 XYZ College. All rights reserved.</p>
<p>Contact: <strong>info@[Link]</strong> | Phone: +1-800-123-4567</p>
</footer>
</body>
</html>
Explanation: - <header> : Contains college logo, name, and tagline - <nav> : Navigation
menu for site sections - <main> : Primary content area - <section> : Groups related
content (Welcome, Departments, Highlights) - <article> : Individual department
information - <aside> : Sidebar with quick links and important dates - <footer> :
Copyright and contact information
[Due to length constraints, I’ll continue with the remaining content in the next section]
— 41 —
UNIT III: LISTS, IMAGES, AND
HYPERLINKS
(25 Pages)
1. ORDERED LISTS
Output:
— 42 —
1.2 Ordered List Types
— 43 —
<li>Seventh item</li>
</ol>
Output:
5. Fifth item
6. Sixth item
7. Seventh item
2. UNORDERED LISTS
<h2>Fruits</h2>
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Orange</li>
<li>Mango</li>
</ul>
Output:
Fruits
• Apple
• Banana
• Orange
• Mango
— 44 —
<li>Item</li>
</ul>
3. NESTED LISTS
<li>Second Year
<ul>
<li>Data Structures</li>
<li>Database Management</li>
<li>Web Development</li>
— 45 —
</ul>
</li>
<li>Third Year
<ul>
<li>Operating Systems</li>
<li>Networking</li>
<li>Software Engineering</li>
</ul>
</li>
</ol>
Output:
2. Second Year
• Data Structures
• Database Management
• Web Development
3. Third Year
• Operating Systems
• Networking
• Software Engineering
<ol>
<li>Item 1
<ol type="a">
<li>Subitem 1.1
<ol type="i">
<li>Sub-subitem 1.1.1</li>
<li>Sub-subitem 1.1.2</li>
</ol>
— 46 —
</li>
<li>Subitem 1.2</li>
</ol>
</li>
<li>Item 2</li>
</ol>
Output:
1. Item 1
a. Subitem 1.1
i. Sub-subitem 1.1.1
ii. Sub-subitem 1.1.2
b. Subitem 1.2
2. Item 2
4. USING IMAGES
Attributes: - src : Path to image file (required) - alt : Alternative text if image doesn’t
load (required for accessibility) - width : Image width in pixels - height : Image height in
pixels - title : Tooltip text on hover
— 47 —
<img src="[Link]" alt="Logo" width="100" height="100">
<style>
.responsive-image {
max-width: 100%;
height: auto;
}
</style>
— 48 —
4.5 Image with Caption
<figure>
<img src="[Link]" alt="College Campus">
<figcaption>Our Beautiful Campus</figcaption>
</figure>
Output:
┌─────────────────┐
│ [College Image] │
└─────────────────┘
Our Beautiful Campus
5. CREATING HYPERLINKS
Components: - <a> : Anchor tag (creates the link) - href : Hyperlink Reference - where
to go - Link text : Text visible to user
— 49 —
<a href="[Link] Email</a>
— 50 —
<!-- Link to anchor on different page -->
<a href="[Link]#introduction">Introduction on Page 2</a>
<!DOCTYPE html>
<html>
<head>
<title>College Website</title>
</head>
<body>
<header>
<h1>ABC College</h1>
</header>
<nav>
<a href="[Link]">Home</a> |
<a href="[Link]">About</a> |
<a href="[Link]">Programs</a> |
<a href="[Link]">Contact</a>
</nav>
<main>
<h2 id="section1">Welcome</h2>
<p>Welcome to our college...</p>
<h2 id="section2">Programs</h2>
<p>We offer various programs...</p>
<h2 id="section3">Admissions</h2>
<p>Apply now for admission...</p>
<footer>
<p>
<a href="[Link] Us</a> |
<a href="[Link] 1-800-123-4567</a>
— 51 —
</p>
</footer>
</body>
</html>
Output:
— 52 —
<!-- Loop count (how many times) -->
<marquee loop="3">Scrolls 3 times then stops</marquee>
<marquee loop="infinite">Scrolls forever</marquee>
<h2>Section 1</h2>
<p>Content of section 1</p>
<hr>
<h2>Section 2</h2>
<p>Content of section 2</p>
Output:
Section 1
Content of section 1
_________________________________
Section 2
Content of section 2
— 53 —
7.2 HR with Styling
<p>
First line<br>
Second line<br>
Third line<br>
Fourth line
</p>
Output:
First line
Second line
Third line
Fourth line
— 54 —
8.2 Multiple Line Breaks
<p>
Paragraph 1<br><br>
Paragraph 2 (with blank line above)
</p>
9. IMPORTANT QUESTIONS
5-MARK QUESTIONS
Q1. Explain ordered and unordered lists with examples.
Ordered lists use <ol> tag and display items with numbers (1, 2, 3…), letters (a, b, c),
or Roman numerals (I, II, III). Use ordered lists for sequences like instructions or
rankings. Example: “Steps to solve a problem” would use ordered list. Unordered lists
use <ul> tag and display items with bullets (•). Use unordered lists for non-sequential
items like features or benefits. Example: “Features of our product” would use unordered
list. Both use <li> tag for each list item. Nested lists combine ordered and unordered
lists to create hierarchical structure - like main topics with sub-topics. This helps
organize information clearly and improves readability.
A nested list is a list within another list, creating a hierarchical structure. Example: A
curriculum outline has years (main items), each year has subjects (nested items).
Nested lists can combine ordered and unordered lists. Syntax: Place <ul> or <ol>
inside <li> of parent list. Real-world example - Course structure: (1) First Semester (2)
Second Semester with sub-items under each. Nested lists improve organization, make
information scannable, and establish clear parent-child relationships between items.
Multiple levels of nesting are possible (main level, sub-level, sub-sub-level). Proper
indentation makes nested lists readable in both HTML code and rendered output.
The <img> tag uses several important attributes: src (required) specifies image file
location - can be local path or URL; alt (required) provides alternative text when image
fails to load and helps blind users understand image content; width and height set
— 55 —
image dimensions in pixels - can prevent layout shift; title displays tooltip text when
hovering over image. Other attributes include style for inline CSS, class for styling
with CSS classes, and loading for lazy loading. Best practices: always include
meaningful alt text, set width and height to avoid layout shift, use optimized image
formats, and provide images in appropriate size to reduce loading time.
Q4. Differentiate between internal links, external links, and email links.
Internal links navigate within the same website using relative paths: <a
href="[Link]">About</a> . External links go to other websites using absolute URLs:
<a href="[Link] . Email links open default email client: <a
href="[Link] Email</a> . Phone links call phone number: <a
href="[Link] . Download links prompt file download: <a
href="[Link]" download>Download</a> . Using target="_blank" opens link in new tab.
Internal links use relative paths (shorter), external links require full URLs ([Link] and
email/phone links use special protocols ([Link] [Link] Each type serves different purpose
in web navigation.
Q5. What is marquee tag and what are its main attributes?
Marquee tag creates scrolling text animation. Main attributes: direction (left, right, up,
down) sets scroll direction; scrollamount controls speed - higher value = faster;
behavior (scroll, slide, alternate) - scroll is continuous, slide goes once and stops,
alternate bounces; loop sets how many times to repeat (number or infinite); bgcolor
sets background color; width and height set dimensions. Example: <marquee
direction="right" loop="infinite">Scrolling text</marquee> . Used for announcements,
alerts, or dynamic content. Note: Marquee is deprecated in modern HTML5, and CSS
animations are preferred for new projects. Marquee can cause accessibility issues for
screen readers and those with motion sensitivity.
10-MARK QUESTIONS
Q1. Create a complete college website page with lists, images, and links.
<!DOCTYPE html>
<html>
<head>
<title>ABC College - Computer Science Department</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
— 56 —
</head>
<body>
<header>
<img src="[Link]" alt="College Logo" width="50" height="50">
<h1>ABC College</h1>
<p>Department of Computer Science</p>
</header>
<marquee bgcolor="lightblue">
📢 Admissions Open! Apply now by June 30, 2024
</marquee>
<nav>
<ul style="list-style-type: none;">
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#programs">Programs</a></li>
<li><a href="#faculty">Faculty</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
<hr>
<main>
<section id="about">
<h2>About Computer Science Department</h2>
<img src="[Link]" alt="CS Department Building" width="400" height="300">
<figcaption>Our State-of-the-art Department Building</figcaption>
<p>
Our <strong>Computer Science Department</strong> is dedicated to providing
<em>world-class education</em> in computing and technology.
</p>
</section>
<hr>
<section id="programs">
<h2>Our Academic Programs</h2>
— 57 —
<h3>Undergraduate Programs</h3>
<ol>
<li>Bachelor of Technology ([Link]) in Computer Science
<ul>
<li>Duration: 4 years</li>
<li>Eligibility: 12th Pass with PCM</li>
<li>Specializations:
<ul>
<li>Web Development</li>
<li>Data Science</li>
<li>Cybersecurity</li>
</ul>
</li>
</ul>
</li>
<li>Bachelor of Science ([Link]) in Computer Science
<ul>
<li>Duration: 3 years</li>
<li>Eligibility: 12th Pass</li>
</ul>
</li>
</ol>
<h3>Postgraduate Programs</h3>
<ul>
<li>Master of Technology ([Link])</li>
<li>Master of Science ([Link])</li>
<li>Diploma in Computer Applications</li>
</ul>
</section>
<hr>
<section id="faculty">
<h2>Faculty Members</h2>
<img src="[Link]" alt="Faculty Members" width="400" height="300">
<h3>Teaching Staff</h3>
<ol>
<li>
<strong>Dr. John Smith</strong> - <em>HOD (Head of Department)</em>
<ul>
— 58 —
<li>Specialization: Artificial Intelligence</li>
<li><a href="[Link] john@[Link]</a></li>
</ul>
</li>
<li>
<strong>Prof. Sarah Johnson</strong>
<ul>
<li>Specialization: Database Systems</li>
<li><a href="[Link] sarah@[Link]</a></li>
</ul>
</li>
<li>
<strong>Prof. Mike Davis</strong>
<ul>
<li>Specialization: Web Development</li>
<li><a href="[Link] mike@[Link]</a></li>
</ul>
</li>
</ol>
</section>
<hr>
<section id="contact">
<h2>Contact Information</h2>
<p>
<strong>Address:</strong> Computer Science Department, ABC College, City, Country<br>
<strong>Phone:</strong> <a href="[Link]
<strong>Email:</strong> <a href="[Link]
<strong>Website:</strong> <a href="[Link] target="_blank">[Link]
</p>
<h3>Important Links</h3>
<ul>
<li><a href="[Link]">Online Admission</a></li>
<li><a href="[Link]" download>Download Fee Structure</a></li>
<li><a href="[Link]">Course Syllabus</a></li>
<li><a href="[Link]">Academic Calendar</a></li>
</ul>
</section>
</main>
— 59 —
<hr>
<footer>
<p>© 2024 ABC College. All rights reserved.</p>
<p>
<a href="#home">Back to Top</a> |
<a href="[Link]">Privacy Policy</a> |
<a href="[Link]">Terms & Conditions</a>
</p>
</footer>
</body>
</html>
Features included: - Multiple internal links with navigation - Nested lists showing
hierarchical structure - Images with captions - External links opening in new tab - Email
and phone links - Download links - Marquee for announcements - Proper use of semantic
elements
(25 Pages)
— 60 —
1. BASIC TABLE STRUCTURE
<table border="1">
<tr>
<th>Name</th>
<th>Age</th>
<th>City</th>
</tr>
<tr>
<td>John</td>
<td>25</td>
<td>New York</td>
</tr>
<tr>
— 61 —
<td>Sarah</td>
<td>28</td>
<td>London</td>
</tr>
</table>
Output:
┌──────┬─────┬──────────┐
│ Name │ Age │ City │
├──────┼─────┼──────────┤
│ John │ 25 │ New York │
├──────┼─────┼──────────┤
│Sarah │ 28 │ London │
└──────┴─────┴──────────┘
<table border="1">
<thead>
<tr>
<th>Roll No</th>
<th>Name</th>
<th>Mathematics</th>
<th>Science</th>
<th>Average</th>
</tr>
</thead>
<tbody>
<tr>
— 62 —
<td>101</td>
<td>Raj Kumar</td>
<td>85</td>
<td>90</td>
<td>87.5</td>
</tr>
<tr>
<td>102</td>
<td>Priya Singh</td>
<td>92</td>
<td>88</td>
<td>90</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Total Students: 2</th>
<th colspan="3">Average Score</th>
<th>88.75</th>
</tr>
</tfoot>
</table>
Output:
┌─────────┬─────────────┬────────────┬─────────┬─────────┐
│Roll No │ Name │ Mathematics│ Science │ Average │
├─────────┼─────────────┼────────────┼─────────┼─────────┤
│101 │ Raj Kumar │ 85 │ 90 │ 87.5 │
├─────────┼─────────────┼────────────┼─────────┼─────────┤
│102 │ Priya Singh │ 92 │ 88 │ 90 │
├─────────┴─────────────┼────────────┼─────────┼─────────┤
│Total Students: 2 │ Average Score │ 88.75 │
└───────────────────────┴────────────┴─────────┴─────────┘
— 63 —
3. ROWSPAN AND COLSPAN
<table border="1">
<tr>
<th>Subject</th>
<th colspan="3">Marks</th>
</tr>
<tr>
<td>Mathematics</td>
<td>85</td>
<td>90</td>
<td>88</td>
</tr>
</table>
Output:
┌────────────┬──────────────────────┐
│ Subject │ Marks │
├────────────┼────┬────┬────────────┤
│ Mathematics│ 85 │ 90 │ 88 │
└────────────┴────┴────┴────────────┘
<table border="1">
<tr>
<th>Subject</th>
<th>Test 1</th>
<th>Test 2</th>
</tr>
<tr>
<td rowspan="2">Mathematics</td>
— 64 —
<td>85</td>
<td>90</td>
</tr>
<tr>
<td>89</td>
<td>92</td>
</tr>
</table>
Output:
┌────────────┬────────┬────────┐
│ Subject │ Test 1 │ Test 2 │
├────────────┼────────┼────────┤
│ │ 85 │ 90 │
│ Mathematics│ │ │
│ │ 89 │ 92 │
└────────────┴────────┴────────┘
<table border="1">
<tr>
<th colspan="2">Student</th>
<th colspan="2">Marks</th>
<th rowspan="2">Grade</th>
</tr>
<tr>
<th>Roll</th>
<th>Name</th>
<th>Theory</th>
<th>Practical</th>
</tr>
<tr>
<td>101</td>
<td>Raj</td>
<td>80</td>
<td>85</td>
<td>A</td>
</tr>
— 65 —
<tr>
<td>102</td>
<td>Priya</td>
<td>90</td>
<td>92</td>
<td>A+</td>
</tr>
</table>
4. TABLE ALIGNMENT
<table border="1">
<tr>
<!-- Horizontal alignment -->
<td align="left">Left Aligned</td>
<td align="center">Center Aligned</td>
<td align="right">Right Aligned</td>
</tr>
<tr>
<!-- Vertical alignment -->
<td valign="top">Top</td>
<td valign="middle">Middle</td>
<td valign="bottom">Bottom</td>
</tr>
</table>
— 66 —
</table>
Output Comparison:
— 67 —
5.2 Cell Spacing
Cell spacing is the space between cells (border spacing).
— 68 —
<td>CS202</td>
<td>Data Structures</td>
<td>Prof. Johnson</td>
<td>25</td>
</tr>
<tr>
<td>CS303</td>
<td>Web Development</td>
<td>Prof. Davis</td>
<td>35</td>
</tr>
</tbody>
</table>
<!DOCTYPE html>
<html>
<head>
<title>Fee Structure</title>
</head>
<body>
<thead>
<tr style="background-color: lightblue;">
<th>Expense Category</th>
<th>[Link]</th>
<th>[Link]</th>
<th>[Link]</th>
</tr>
— 69 —
</thead>
<tbody>
<tr>
<td><strong>Tuition Fee</strong></td>
<td>₹ 1,50,000</td>
<td>₹ 80,000</td>
<td>₹ 2,00,000</td>
</tr>
<tr>
<td><strong>Laboratory Fee</strong></td>
<td>₹ 25,000</td>
<td>₹ 15,000</td>
<td>₹ 30,000</td>
</tr>
<tr>
<td><strong>Library Fee</strong></td>
<td>₹ 5,000</td>
<td>₹ 5,000</td>
<td>₹ 5,000</td>
</tr>
<tr>
<td><strong>Student Activity Fee</strong></td>
<td>₹ 10,000</td>
<td>₹ 8,000</td>
<td>₹ 10,000</td>
</tr>
</tbody>
<tfoot>
<tr style="background-color: lightyellow;">
<th><strong>Total Annual Fee</strong></th>
<th>₹ 1,90,000</th>
<th>₹ 1,08,000</th>
<th>₹ 2,45,000</th>
</tr>
</tfoot>
</table>
</body>
</html>
— 70 —
6.2 Class Schedule Table
<thead>
<tr>
<th>Time</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>9:00-10:00</strong></td>
<td>Programming</td>
<td>Mathematics</td>
<td>Database</td>
<td>Programming</td>
<td>Web Dev</td>
</tr>
<tr>
<td><strong>10:00-11:00</strong></td>
<td colspan="5" align="center"><em>Break</em></td>
</tr>
<tr>
<td><strong>11:00-12:00</strong></td>
<td>Mathematics</td>
<td>Database</td>
<td>Programming</td>
<td>Web Dev</td>
<td>Mathematics</td>
</tr>
<tr>
<td><strong>12:00-1:00</strong></td>
<td colspan="5" align="center"><em>Lunch</em></td>
</tr>
— 71 —
<tr>
<td><strong>1:00-2:00</strong></td>
<td>Lab</td>
<td>Lab</td>
<td>Lab</td>
<td>Lab</td>
<td>Seminar</td>
</tr>
</tbody>
</table>
7. IMPORTANT QUESTIONS
5-MARK QUESTIONS
Q1. Explain table structure and its main components.
Rowspan merges cells vertically across multiple rows. Syntax: <td rowspan="3">content</
td> merges 3 rows. Colspan merges cells horizontally across multiple columns. Syntax:
<td colspan="2">content</td> merges 2 columns. Uses: Rowspan for grouping related
vertical data (like time periods), colspan for merged headers spanning multiple columns.
Example rowspan: In attendance table, student name spans multiple attendance entries.
Example colspan: In report card, “Marks” header spans “Theory” and “Practical”
columns. These attributes help create complex table layouts and improve readability by
reducing data redundancy and highlighting relationships.
— 72 —
Q3. Explain cell padding and cell spacing with examples.
Cell padding is space inside cells between content and borders - created with
cellpadding attribute. Increases readability by providing breathing room for content.
Example: <table cellpadding="10"> adds 10 pixels inside all cells. Cell spacing is space
between cells (border-spacing) - created with cellspacing attribute. Affects gap
between adjacent cells. Example: <table cellspacing="5"> creates 5-pixel gap between
cells. Together they control whitespace: padding inside cells, spacing between cells.
Proper spacing improves visual hierarchy and readability. Padding=0 makes text touch
cell borders (crowded), padding=10 gives space (readable). Spacing=0 makes table
compact, spacing=5 separates cells clearly.
Cell alignment controls position of content within cells: horizontal alignment (left, center,
right) and vertical alignment (top, middle, bottom). Syntax: <td align="center"
valign="middle"> centers content horizontally and vertically. Horizontal alignment - left
aligns to left edge, center places in middle, right aligns to right edge. Vertical alignment
- top places at top edge, middle centers vertically, bottom at bottom. Table alignment
positions entire table on page: <table align="center"> centers table. Modern practice
uses CSS for alignment instead of HTML attributes. Example: For headers use center
alignment, for content use left-aligned text and right-aligned numbers. Proper alignment
improves readability and visual organization.
Q5. What are thead, tbody, and tfoot elements and their purpose?
These semantic elements group table rows into logical sections: <thead> contains
header rows appearing at top, <tbody> contains main data rows, <tfoot> contains
footer rows appearing at bottom. Benefits: (1) Improved accessibility - screen readers
understand table structure, (2) Easier styling - target specific sections with CSS, (3)
Semantic meaning - makes code clearer, (4) Better printing - browsers handle page
breaks appropriately. Example: Financial table has <thead> with column titles, <tbody>
with transaction rows, <tfoot> with totals. Proper structure separates header from data,
making tables more organized and easier to maintain. These elements don’t change
appearance but improve code organization and accessibility.
10-MARK QUESTIONS
Q1. Create a complex student marks table with all table features (rowspan,
colspan, padding, spacing, sections).
— 73 —
<!DOCTYPE html>
<html>
<head>
<title>Student Marks Report</title>
</head>
<body>
<thead>
<tr style="background-color: darkblue; color: white;">
<th>Roll No</th>
<th>Student Name</th>
<th colspan="2">Internal Marks</th>
<th colspan="2">Practical</th>
<th colspan="2">Final Exam</th>
<th>Total</th>
<th>Grade</th>
</tr>
<tr style="background-color: lightblue;">
<th colspan="2"></th>
<th>Theory</th>
<th>Assignment</th>
<th>Lab Work</th>
<th>Viva</th>
<th>Written</th>
<th>Practical</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">101</td>
<td>Rajesh Kumar</td>
<td align="center">18</td>
— 74 —
<td align="center">9</td>
<td align="center">8</td>
<td align="center">9</td>
<td align="center">42</td>
<td align="center">18</td>
<td align="center">104</td>
<td align="center"><strong>A</strong></td>
</tr>
<tr>
<td align="center">102</td>
<td>Priya Singh</td>
<td align="center">19</td>
<td align="center">10</td>
<td align="center">9</td>
<td align="center">10</td>
<td align="center">45</td>
<td align="center">20</td>
<td align="center">113</td>
<td align="center"><strong>A+</strong></td>
</tr>
<tr>
<td align="center">103</td>
<td>Amit Patel</td>
<td align="center">16</td>
<td align="center">8</td>
<td align="center">7</td>
<td align="center">8</td>
<td align="center">38</td>
<td align="center">16</td>
<td align="center">93</td>
<td align="center"><strong>B+</strong></td>
</tr>
<tr>
<td align="center">104</td>
<td>Neha Sharma</td>
<td align="center">17</td>
<td align="center">9</td>
<td align="center">8</td>
<td align="center">9</td>
— 75 —
<td align="center">41</td>
<td align="center">17</td>
<td align="center">101</td>
<td align="center"><strong>A</strong></td>
</tr>
</tbody>
<tfoot>
<tr style="background-color: lightyellow; font-weight: bold;">
<td colspan="2">Class Average</td>
<td align="center">17.5</td>
<td align="center">9</td>
<td align="center">8</td>
<td align="center">9</td>
<td align="center">41.5</td>
<td align="center">17.75</td>
<td align="center">102.75</td>
<td align="center">A</td>
</tr>
</tfoot>
</table>
<h3>Grade Scale:</h3>
<ul>
<li>A+ : 110-120</li>
<li>A : 100-109</li>
<li>B+ : 90-99</li>
<li>B : 80-89</li>
<li>C+ : 70-79</li>
<li>C : 60-69</li>
</ul>
</body>
</html>
Features demonstrated: - Colspan for merged header cells - Thead, tbody, tfoot
sections - Cellpadding and cellspacing - Cell alignment (center) - Background colors for
sections - Clear table structure - Professional formatting
— 76 —
UNIT V: FRAMES AND FORMS
(25 Pages)
1. FRAMES
Note: Frames are deprecated in HTML5. Modern alternatives include: CSS layout,
flexbox, grid, or iframes.
<!DOCTYPE html>
<html>
<head>
<title>Frames Example</title>
</head>
<frameset rows="20%, 80%">
<frame src="[Link]" noresize>
<frame src="[Link]" noresize>
</frameset>
</html>
— 77 —
<frameset rows="30%, 70%">
<frame src="[Link]">
<frame src="[Link]">
</frameset>
Complex Layout:
Attribute Purpose
— 78 —
1.5 Targeted Links
Links can target specific frames using the target attribute:
<noframes>
<p>Your browser does not support frames.</p>
<p><a href="[Link]">Click here for non-frame version</a></p>
</noframes>
</frameset>
2. FORMS
— 79 —
Attributes: - action - URL of script to process form - method - How to send data (GET,
POST)
— 80 —
<input type="time" name="appointment">
<select name="country">
<option value="">-- Select Country --</option>
<option value="usa">United States</option>
<option value="india">India</option>
<option value="uk">United Kingdom</option>
<option value="australia">Australia</option>
</select>
<!DOCTYPE html>
<html>
<head>
<title>Student Registration Form</title>
</head>
<body>
— 81 —
<form action="[Link]" method="POST">
<label for="semester">Semester:</label>
<select id="semester" name="semester">
<option value="1">1st Semester</option>
<option value="2">2nd Semester</option>
<option value="3">3rd Semester</option>
<option value="4">4th Semester</option>
— 82 —
</select>
<br><br>
<label>Gender:</label>
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female
<input type="radio" name="gender" value="other"> Other
<br><br>
</fieldset>
<label for="comments">Comments:</label><br>
<textarea id="comments" name="comments" rows="5" cols="50">
Write any additional information...
</textarea>
<br><br>
</fieldset>
— 83 —
<input type="submit" value="Register">
<input type="reset" value="Clear Form">
</form>
</body>
</html>
Output:
Personal Information
Full Name: [____________]
Email Address: [_____________@[Link]]
Phone Number: [____________]
Date of Birth: [__/__/____]
Academic Information
Select Course: [▼ -- Select Course --]
Semester: [▼ 1st Semester]
Gender:
○ Male ○ Female ○ Other
Interests
☑ Sports ☑ Music ☐ Coding ☐ Arts
Additional Comments
Comments:
[_____________________________]
[_____________________________]
[_____________________________]
Agreement
☑ I agree to the terms and conditions
— 84 —
2.7 Label Tag
The <label> tag associates text with form elements:
<label for="username">Username:</label>
<input type="text" id="username" name="username">
— 85 —
3.4 Readonly and Disabled
<fieldset>
<legend>Personal Details</legend>
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<br>
<label for="age">Age:</label>
<input type="number" id="age" name="age">
</fieldset>
<fieldset>
— 86 —
<legend>Address</legend>
<label for="address">Street:</label>
<input type="text" id="address" name="address">
<br>
<label for="city">City:</label>
<input type="text" id="city" name="city">
</fieldset>
5. IMPORTANT QUESTIONS
5-MARK QUESTIONS
Q1. Explain frames and their purpose. What are the drawbacks?
Frames divide browser window into multiple rectangular sections, each displaying
separate HTML document. Created with <frameset> containing <frame> tags. Purpose:
Allow simultaneous display of multiple documents (e.g., navigation menu + content
area). Can be arranged horizontally (rows) or vertically (cols). Drawbacks: (1)
Bookmarking specific pages difficult, (2) Search engines can’t index properly, (3)
Complex navigation and linking, (4) Accessibility issues for screen readers, (5) Modern
browsers handle poorly, (6) Deprecated in HTML5. Modern alternatives: CSS layouts,
flexbox, grid, or iframes. Frames were popular in 1990s-2000s but now considered
outdated. Recommended to avoid frames in new projects and use modern CSS layout
techniques instead.
Q2. What are forms and what input types are available?
Forms collect user input through various elements. <form> tag creates form container
with action (where to send data) and method (GET/POST) attributes. Input types
include: (1) text - single-line text, (2) password - masked text, (3) email - email format,
(4) number - numeric values, (5) checkbox - multiple selections, (6) radio - single
selection, (7) submit - submit button, (8) reset - clear form, (9) file - file upload, (10) date
- date picker, (11) time - time picker, (12) color - color picker, (13) range - slider. Other
elements: <textarea> for multi-line text, <select> for dropdown menu, <option> for
menu items. Each input has name attribute for form submission and various other
attributes for validation and behavior.
— 87 —
Q3. Explain textarea, select, and option tags with examples.
<textarea> creates multi-line text input for longer text: <textarea name="comments"
rows="5" cols="40"></textarea> . Attributes: rows (height), cols (width). <select> creates
dropdown menu: <select name="country"><option>Option 1</option></select> . <option>
defines each menu item with value attribute for form submission. Example: Select
course from dropdown showing multiple options. User clicks to expand, selects one
option. Selected option’s value is submitted with form. <optgroup> can group related
options. Difference: textarea allows multiple lines of free text, select restricts choice to
predefined options. Use textarea for feedback/comments, select for categories/choices.
Q4. What are label and fieldset tags and their purposes?
<label> associates descriptive text with form element. Syntax: <label for="id">Text</
label><input id="id"> . Benefits: (1) Click-able - users can click label to focus/toggle
input, (2) Accessibility - screen readers read label, (3) Semantic - proper HTML structure.
Improves usability especially for checkboxes and radio buttons. <fieldset> groups
related form elements with visual border. <legend> provides title for fieldset. Example:
Personal Information fieldset contains name, email, phone inputs. Separates form into
logical sections. Benefits: (1) Better organization, (2) Improved visual grouping, (3)
Accessibility - screen readers announce groups. Fieldset adds visual border, legend
appears as border label. Both improve form usability and accessibility for all users.
Q5. What are form attributes like required, readonly, disabled, and pattern?
Form input attributes enhance validation and behavior: (1) required - field must be
filled before submission, (2) readonly - value can’t be changed but is submitted, (3)
disabled - field can’t be changed, focused, or submitted, (4) placeholder - hint text
showing before user types, (5) min/max - numeric or date range, (6) pattern - regex
validation rule, (7) title - error message. Example: <input type="email" required>
makes email mandatory. <input readonly> shows but protects field value. <input
pattern="[0-9]{10}"> validates phone format. These attributes improve user experience
by: providing guidance, preventing errors, auto-validating input. Browser handles
validation before form submission, reducing server load and providing instant feedback
to users.
10-MARK QUESTIONS
Q1. Design a complete college online admission form with all form elements
and proper structure.
— 88 —
<!DOCTYPE html>
<html>
<head>
<title>ABC College - Online Admission Form</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<label>Gender:</label>
<input type="radio" name="gender" value="male" required> Male
<input type="radio" name="gender" value="female"> Female
<input type="radio" name="gender" value="other"> Other
<br><br>
— 89 —
<textarea id="address" name="address" rows="3" cols="40" required></textarea>
<br><br>
<label for="city">City:</label>
<input type="text" id="city" name="city" required>
<br><br>
<label for="state">State/Province:</label>
<input type="text" id="state" name="state" required>
<br><br>
— 90 —
<!-- Section 3: Course Selection -->
<fieldset>
<legend><strong>Section 3: Course Selection</strong></legend>
<label for="achievements">Achievements/Awards:</label>
<textarea id="achievements" name="achievements" rows="3" cols="40" placeholder="Mention any awards
<br><br>
</fieldset>
— 91 —
<!-- Section 5: Document Upload -->
<fieldset>
<legend><strong>Section 5: Document Upload</strong></legend>
<p>
<strong>Declaration:</strong> I hereby declare that the information provided
above is true and correct to the best of my knowledge. I understand that
any false information may lead to cancellation of my admission.
</p>
— 92 —
<!-- Hidden field -->
<input type="hidden" name="form_version" value="1.0">
<input type="hidden" name="submission_date" value="">
</form>
<hr>
<footer>
<p><strong>Note:</strong> All fields marked with * are mandatory.</p>
<p>For help: <a href="[Link] | Phone: +1-800-1
</footer>
</body>
</html>
Form Features Demonstrated: - Organized sections with fieldset and legend - Various
input types (text, email, date, number, radio, checkbox, file, select) - Form validation
attributes (required, pattern, min, max) - Textarea for multi-line input - File upload
capabilities - Hidden fields - Submit and reset buttons - Clear navigation and accessibility
— 93 —
• Font style elements (bold, italic, etc.)
— 94 —
8. Accessibility: Always use alt text, labels, and semantic HTML
Total Pages: ~125 pages equivalent of detailed content with examples, diagrams, code
samples, and questions for all 5 units.
— 95 —