Web Unit 1 Chapter-2
Web Unit 1 Chapter-2
HTML/XHTML
Origins and Evolution of HTML and
XHTML
1. Introduction to HTML
• HTML (Hypertext Markup Language) is a markup
language used to structure web documents.
• Defined using Standard Generalized Markup
Language (SGML), an ISO standard.
• Unlike other formatting languages, HTML focuses on
document structure rather than detailed presentation
(fonts, colors, etc.).
• Early versions of HTML were designed to work across
different browsers and operating systems.
Evolution of HTML and Browser Wars
• Early 1990s: HTML was developed alongside the
World Wide Web at CERN (European Laboratory for
Particle Physics).
• 1993: Web’s popularity grew with the release of
MOSAIC, the first graphical web browser.
• 1995: Microsoft launched Internet Explorer (IE),
competing with Netscape, leading to the Browser
Wars (1995–1999).
• Netscape and Microsoft added their own extensions,
creating incompatibilities in HTML.
Role of W3C in Standardization
• 1994: Tim Berners-Lee founded W3C (World Wide
Web Consortium) to standardize HTML.
• W3C released HTML versions to keep up with browser
innovations:
• HTML 2.0 (1995) – First official standard.
• HTML 3.2 (1997) – Incorporated browser innovations.
• HTML 4.0 (1997) – Major improvements.
• HTML 4.01 (1999) – Last major HTML update before XHTML.
Problems with HTML 4.01
• Loose Syntax Rules – Allowed inconsistent document
structures, leading to compatibility issues across
browsers.
• Error Handling Issues – HTML did not define how
browsers should recover from errors, leading to
inconsistent interpretations.
• Deprecated Features – Some older features were
phased out but still supported in browsers.
Transition to XHTML (2000-2001)
• XML (Extensible Markup Language) introduced strict
syntax rules for data representation.
• XHTML 1.0 (2000) redefined HTML 4.01 using XML,
enforcing stricter syntax rules.
• Three XHTML 1.0 Standards:
• Strict – Follows all syntax rules.
• Transitional – Allows deprecated features.
• Frameset – Allows frame-based layouts.
• XHTML 1.1 (2001) removed frames and enforced strict
syntax rules ("draconian error handling").
• XHTML 2.0 (proposed later) was not backward
compatible, leading to its decline.
Rise of HTML5 and Decline of XHTML
2.0
• 2004: The Web Hypertext Application Technology
(WHAT) Working Group was formed by browser vendors
and developers.
• Goals of WHATWG:
• Maintain backward compatibility with HTML 4.01.
• Define clear error handling in the specification.
• Prevent users from seeing syntax errors in web documents.
• 2006: W3C abandoned XHTML 2.0 and joined WHATWG to
develop a new HTML version.
• 2009: W3C officially dropped XHTML 2.0 and adopted
the new standard, naming it HTML5.
Summary
• HTML was developed as a document structuring
language, not a design tool.
• The Browser Wars led to incompatible HTML
versions.
• W3C standardized HTML to reduce inconsistencies.
• XHTML introduced strict rules but was unpopular
due to its strict error handling.
• HTML5 replaced XHTML as the new standard,
focusing on compatibility, flexibility, and usability.
HTML vs. XHTML
The Shift from XHTML to HTML5
• Until 2010, many developers preferred XHTML for its
strict syntax rules, standardization, and validation.
• However, browsers still processed XHTML documents
using HTML parsers when served as text/html.
• Some developers stuck with HTML, while others were
disappointed that W3C abandoned XHTML’s strict
enforcement.
• HTML5 adoption made XHTML validation impossible
with the W3C XHTML 1.0 Strict validator.
Advantages of XHTML Over HTML
• Standards and Consistency
• XHTML enforces strict syntactic rules, ensuring uniform structure across
documents.
• HTML allows flexibility, leading to inconsistent formatting.
• Error Handling
• XHTML rejects incorrect code, ensuring documents are well-formed.
• HTML tolerates errors, causing inconsistent displays across browsers.
• Quality in Development
• Just as structured programming improves software quality, XHTML
improves document quality.
• Poorly structured HTML is common, but that doesn’t justify creating
more sloppy documents.
Choosing Between HTML and XHTML
• Key Considerations:
• Is the strict discipline of XHTML worth the improved clarity and
uniform display across browsers?
• Is validation worth the extra effort?
• A Compromise Approach:
• Promote HTML5 but follow XHTML 1.0 Strict syntax
rules (since they are valid in HTML5).
• Ensures document consistency while leveraging HTML5’s
new features.
Basic HTML Syntax
1. Tags and Elements
HTML documents use tags to define content categories.
Tag syntax: <tagname> (opening tag) and </tagname>
(closing tag).
Example of an element:
<p>This is simple stuff.</p>
Tags must be in lowercase (<p> not <P>).
2. Attributes
Attributes modify tag behavior.
• Format: attribute="value", enclosed in double
quotes.
Example:
html
HTML 2.
3.
A heading (<h1>) with your name.
A paragraph (<p>) describing your favorite hobby.
Text 4. Use bold (<strong>) and italic (<em>) text in your
paragraph.
Formatti 5. Insert a line break (<br />) in the paragraph.
Practice 7.
8.
Add a horizontal rule (<hr />) to separate sections.
Include a subscript (<sub>) or superscript (<sup>)
Exercise 9.
in a math or chemical formula.
Use special characters like © or €.
10. Save the file as practice.html and open it in a
browser.
HTML Lists: Unordered, Ordered &
Definition Lists
HTML provides three main types of lists:
• 1️⃣Unordered Lists (<ul>) – Lists with bullet points
• 2️⃣Ordered Lists (<ol>) – Lists with numbers or letters
• 3️⃣Definition Lists (<dl>) – Lists with terms and
definitions
1 Unordered Lists (<ul>)
• Unordered lists are used when the order of items does not matter (e.g., grocery lists).
<!DOCTYPE html>
<html lang="en">
<head>
<title>Unordered List Example</title>
</head>
<body>
<h3>Some Common Single-Engine Aircraft</h3>
<ul>
<li>Cessna Skyhawk</li>
<li>Beechcraft Bonanza</li>
<li>Piper Cherokee</li>
</ul>
</body>
</html>
Output :
✅ Default display:
• Cessna Skyhawk
• Beechcraft Bonanza
• Piper Cherokee
2 Ordered Lists (<ol>)
• Ordered lists are lists in which the order of items is
important. This orderedness of a list is shown in the
display of the list by the implicit attachment of a
sequential value to the beginning of each item. The
default sequential values are Arabic numerals,
beginning with 1. An ordered list is created within the
block tag
• . The items are specified and displayed just as are those
in unordered lists, except that the items in an ordered
list are preceded by sequential values instead of bullets.
Example
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Ordered List Example</title>
</head>
<body>
<h3>Cessna 210 Engine Starting Instructions</h3>
<ol>
<li>Set mixture to rich</li>
<li>Set propeller to high RPM</li>
<li>Set ignition switch to "BOTH"</li>
<li>Set auxiliary fuel pump switch to "LOW PRIME"</li>
<li>When fuel pressure reaches 2 to 2.5 PSI, push starter button</li>
</ol>
</body>
</html>
Output
Nested Lists
<h3>Aircraft Types</h3>
<ol>
<li>General Aviation (Piston-Driven Engines)
<ol>
<li>Single-Engine Aircraft
<ol>
<li>Tail Wheel</li>
<li>Tricycle</li>
</ol>
</li>
<li>Dual-Engine Aircraft
<ol>
<li>Wing-mounted engines</li>
<li>Push-pull fuselage-mounted engines</li>
</ol>
</li>
</ol>
</li>
<li>Commercial Aviation (Jet Engines)
<ol>
<li>Dual-Engine
<ol>
<li>Wing-mounted engines</li>
<li>Fuselage-mounted engines</li>
</ol>
</li>
Continue..
<li>Tri-Engine
<ol>
<li>Third engine in vertical stabilizer</li>
<li>Third engine in fuselage</li>
</ol>
</li>
</ol>
</li>
</ol>
Output
Definition Lists (<dl>)
• Definition lists are used to display terms and their
meanings, like a glossary.
• A definition list is given as the content of a dl element,
which is a block element. Each term to be defined in the
definition list is given as the content of a dt element.
The definitions themselves are specified as the content
of dd elements. The defined terms of a definition list are
usually displayed in the left margin; the definitions are
usually shown indented on the line or lines following the
term, as in the following example:
example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Definition List Example</title>
</head>
<body>
<h3>Single-Engine Cessna Airplanes</h3>
<dl>
<dt>152</dt>
<dd>Two-place trainer</dd>
<dt>172</dt>
<dd>Smaller four-place airplane</dd>
Contd..
<dt>182</dt>
<dd>Larger four-place airplane</dd>
<dt>210</dt>
<dd>Six-place airplane - high performance</dd>
</dl>
</body>
</html>
Output
Key Takeaways
🔹 Use <ul> when order does NOT matter.
🔹 Use <ol> when order IS important.
🔹 Use <dl> for term-definition pairs (glossaries).
🔹 Lists can be nested for better structure.
Introduction to Tables
Definition:
• Tables are widely used in printed materials and web
documents to organize and display data efficiently.
• A table consists of a matrix of cells arranged in rows
and columns.
• The first row and first column often contain labels
(headings), while the remaining cells hold the actual
data.
• Table cells can contain text, headings, images,
horizontal rules, or even nested tables.
Basic Table Tags
Structure of a Table
• <table> → Defines the table.
• <tr> (Table Row) → Defines a row.
• <th> (Table Header) → Defines column or row labels
(bold and centered by default).
• <td> (Table Data) → Defines the data cells in a table.
• <caption> → Provides a title for the table.
Example of a Basic Table
<table>
<caption>Fruit Juice Drinks</caption>
<tr>
<th></th> <!-- Empty top-left corner -->
<th>Apple</th>
<th>Orange</th>
<th>Screwdriver</th>
</tr>
<tr>
<th>Breakfast</th>
<td>0</td>
<td>1</td>
<td>0</td>
Contd..
</tr>
<tr>
<th>Lunch</th>
<td>1</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>Dinner</th>
<td>0</td>
<td>0</td>
<td>1</td>
</tr>
</table>
Output
The rowspan and colspan Attributes
🔹 Purpose of rowspan and colspan
• These attributes help structure multi-level table
headers and row labels.
• colspan → Expands a cell across multiple columns.
• rowspan → Expands a cell across multiple rows.
• These attributes improve readability and reduce
redundant code in tables.
Example of colspan (Merging
Columns)
<tr>
<th colspan="3">Fruit Juice Drinks</th>
</tr>
<tr>
<th>Apple</th>
<th>Orange</th>
<th>Screwdriver</th>
</tr>
Explanation: