Unit-2 HTML: Basics of HTML,
Unit-2 HTML: Basics of HTML,
tables, images, forms, XHTML, Meta tags, Character entities, frames and frame sets, Browser
architecture and Web site structure. Overview and features of HTML5
Basics of HTML
1. HTML (Hypertext Markup Language) is a standard markup language for web pages.
2. Basic structure: <!DOCTYPE html>, <html>, <head>, <body>.
3. Elements: Tags (<tag>) with attributes (attr="value").
4. Syntax: Closing tags (</tag>) and proper nesting.
Commenting Code
1. Syntax: <!-- comment -->.
2. Purpose: Hide code from browsers, explain code.
Color
1. Color codes: Hexadecimal (#RRGGBB) or RGB (rgb(R,G,B)).
2. Background color: <body bgcolor="#RRGGBB">.
3. Text color: <font color="#RRGGBB">.
Hyperlinks
Lists
Tables
Images
Forms
XHTML
Meta Tags
Character Entities
1. & (ampersand).
2. < (less-than).
3. > (greater-than).
4. " (quotation mark).
Browser Architecture
1. User Interface.
2. Rendering Engine (Blink, Gecko).
3. JavaScript Engine (V8).
4. Networking.
5. Storage.
1. Responsive design.
2. Mobile-friendly.
3. Improved performance.
4. Enhanced security.
5. Better accessibility.
Q.1]. What are the different types of lists in HTML? Explain with suitable
examples. (AL Nov-2023) (CY May-2023) (CS 2020)
Different Types of Lists in HTML
HTML provides several ways to create lists. The three main types of lists are:
1. Ordered List (ol)
2. Unordered List (ul)
3. Definition List (dl)
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
Output:
1. Item 1
2. Item 2
3. Item 3
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
Output:
• Item 1
• Item 2
• Item 3
<dl>
<dt>Term 1</dt>
<dd>Definition 1</dd>
<dt>Term 2</dt>
<dd>Definition 2</dd>
</dl>
Output:
Term 1
Definition 1
Term 2
Definition 2
4.Nested Lists
<ul>
<li>Item 1</li>
<li>Item 2
<ul>
<li>Subitem 1</li>
<li>Subitem 2</li>
</ul>
</li>
</ul>
Output:
• Item 1
• Item 2
• Subitem 1
• Subitem 2
Menu Lists
1. Lists for navigation menus.
2. Syntax: <menu>, <li> (list item).
3. Example:
<menu>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</menu>
Q.2]. Explain how images can be inserted into HTML documents. (AL Nov-
2023)
Inserting Images into HTML Documents
To insert images into HTML documents, you use the <img> tag. This tag is a self-closing tag,
meaning it does not have a closing tag. The <img> tag has several attributes that help in
defining the source and appearance of the image
Methods
3. Example:
<img src="image.jpg" alt="Beautiful Landscape" width="500" height="300">
Image Sources
1. Local files: src="image.jpg" (same directory)
2. Relative paths: src="images/image.jpg" (subdirectory)
3. Absolute URLs: src="(link unavailable)" (external website)
4. Base64 encoded: src="data:image/jpeg;base64,..." (inline images)
Accessibility Considerations
1. Provide alternative text (alt attribute)
2. Use descriptive file names
3. Avoid using images for text
4. Ensure sufficient contrast
Best Practices
1. Optimize image file size
2. Use meaningful file names
3. Specify image dimensions
4. Test image rendering
Additional Attributes
1. title: Image tooltip
2. longdesc: Detailed image description
3. usemap: Image map association
4. ismap: Image map specification
Summary:
The <img> tag is used to insert images into HTML documents. By using attributes like , src,alt, title,
width, and height, you can control the source, alternative text, tooltip, and dimensions of the
image. This helps in creating visually appealing and accessible web pages.
Q.3]. Write an HTML document to divide your browsing window into 3 parts
consisting of 2 rows of size 20%
and 80%, and divide the last row
into two columns of size 30% and
70%. (CS Nov-2023)
Explanation:
<style>: Contains the CSS to style the
layout.
.row1: Defines the height of the first row
to be 20% of the window height and sets
a background color.
.row2: Defines the height of the second
row to be 80% and uses display: flex to
arrange its child elements (columns).
.column1: Sets the width of the first
column in the second row to 30% and
sets a background color.
.column2: Sets the width of the second
column in the second row to 70% and
sets a background color.
Q.4]. Discuss the difference between HTML and XHTML with respect to
elements. (CY May-2023) (AD 2022) (CS Nov-2023)
or
Differentiate HTML and XHTML with suitable examples.
Document Type
Declaration (DTD) Optional Mandatory
Mandatory (e.g.,
Namespace Optional xmlns="http://www.w3.org/1999/xhtml")
Case Sensitivity Not case-sensitive (e.g., <BR>) Case-sensitive (e.g., <br />)
Some tags do not require closing All tags must be properly closed (e.g.,
Tag Closure
(e.g., <img>) <img />)
Document Type
Optional Mandatory
Declaration (DTD)
Commenting Code
1. Syntax: <!-- comment -->
Color
1. Hexadecimal Code: #RRGGBB
2. RGB Code: rgb(R,G,B)
3. Color Names: red, blue, etc.
Hyperlinks
1. Internal Links: <a href="#anchor">
2. External Links: <a href="(link unavailable)">
3. Email Links: <a href="mailto:email@example.com">
Lists
1. Ordered Lists: <ol>, <li>
2. Unordered Lists: <ul>, <li>
3. Definition Lists: <dl>, <dt>, <dd>
Tables
1. Basic Table: <table>, <tr>, <td>
2. Table Headers: <th>
3. Table Rows: <tr>
4. Table Data: <td>
Images
1. Image Tag: <img src="image_url" alt="image_description">
2. Image Attributes: width, height, border, alt
Forms
1. Form Tag: <form>
2. Input Fields: <input type="text/password/email/etc.">
3. Submit Button: <input type="submit">
4. Reset Button: <input type="reset">
XHTML
1. DOCTYPE Declaration: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"(link unavailable)">
2. XML Namespace: xmlns="(link unavailable)"
3. Self-Closing Tags: <br />, <img />
Meta Tags
1. Charset: <meta charset="UTF-8">
2. Description: <meta name="description" content="Page description">
3. Keywords: <meta name="keywords" content="Page keywords">
4. Author: <meta name="author" content="Page author">
Character Entities
1. Ampersand: &
2. Less-than: <
3. Greater-than: >
4. Quotation Mark: "
5. Non-breaking Space:
Key Features
1. Semantic Elements: New elements like <header>, <nav>, <main>, <section>, <article>,
<aside>, <footer>, and <figure> provide better structure and meaning to web pages.
2. Multimedia Support: Native support for audio and video playback using <audio> and
<video> elements.
3. Canvas and SVG: Enhanced graphics capabilities using <canvas> and SVG (Scalable Vector
Graphics).
4. Offline Storage: LocalStorage and sessionStorage allow web applications to store data
locally.
5. Geolocation API: Access device location information.
6. Microdata: Semantic markup for search engines and other applications.
7. Improved Error Handling: Better error handling and recovery mechanisms.
8. Responsive Design: Improved support for mobile devices and responsive design.
9. Web Workers: Run background scripts, improving performance.
10. Web Sockets: Real-time communication between web applications and servers.
11. New Input Types: Enhanced form input types, such as date, time, email, and URL.
12. Improved Accessibility: Better support for accessibility features.
Additional Features
Benefits
Browser Support
HTML5 is supported by all modern browsers, including:
1. Google Chrome
2. Mozilla Firefox
3. Microsoft Edge
4. Safari
5. Opera
Resources
1. W3C HTML5 Specification
2. Mozilla Developer Network (MDN) HTML5 Documentation
3. HTML5 Tutorial by W3Schools
4. HTML5 Reference by Mozilla Developer Network
HTML5 brings numerous enhancements to web development, including new semantic elements,
multimedia support, improved form controls, enhanced graphics capabilities, and powerful
APIs for better interactivity and performance.
Summary:
Browser Architecture: Involves components like the user interface, browser engine,
rendering engine, networking, JavaScript interpreter, UI backend, and data storage working
together to render web content.
Website Structure: Refers to the organization of a website’s content, files, and navigation to
ensure a seamless and user-friendly experience.
Browser Architecture
1. Rendering Engine: Converts HTML, CSS, JavaScript into visual content
2. JavaScript Engine: Executes JavaScript code
3. Networking: Handles HTTP requests/responses
4. Security: Implements security features
5. User Interface: Browser window, toolbar, address bar
Website Structure
1. Home Page: Main entry point
2. Navigation: Menu, links, buttons
3. Content Pages: Individual pages
4. Static Assets: Images, CSS, JavaScript files
5. Dynamic Content: Server-generated content
Key Components
1. HTML: Structure and content
2. CSS: Layout, styling, design
3. JavaScript: Interactivity, dynamic effects
4. Images: Graphics, logos, icons
5. Videos: Multimedia content
Website Types
1. Static Website: Pre-built HTML, CSS, JavaScript
2. Dynamic Website: Server-generated content
3. Responsive Website: Adapts to devices, screen sizes
4. Single-Page Application (SPA): JavaScript-driven
5. Progressive Web App (PWA): Offline-capable, installable
Best Practices
1. Accessibility: Follow WCAG guidelines
2. Search Engine Optimization (SEO): Optimize for search engines
3. Performance: Minimize load times
4. Security: Implement HTTPS, validate user input
5. Responsive Design: Ensure cross-device compatibility