Web unit 1
Web unit 1
2. What is HTML?
Definition:
HTML (HyperText Markup Language) is the standard markup language used to create and
design documents displayed in a web browser. It describes the structure of a web page using
elements (also called tags), which define headings, paragraphs, links, images, and other
content.
Purpose of HTML:
• Structures web content.
• Supports multimedia like images, videos, and audio.
• Links documents through hypertext.
• Enables embedding of scripts (like JavaScript).
• Acts as the skeleton of every website.
Basic Structure of an HTML Document:
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
</head>
<body>
<h1>Welcome to My Website</h1>
<p>This is a sample paragraph.</p>
</body>
</html>
Explanation:
• <!DOCTYPE html>: Declares the document type and version of HTML.
• <html>: Root element.
• <head>: Contains metadata (not visible on the page).
• <title>: Displays title on the browser tab.
• <body>: Contains all visible content like headings, text, images, etc.
3. Evolution of HTML
HTML has evolved over time through various versions:
• HTML 1.0 (1993): Basic elements.
• HTML 2.0 (1995): Standardized existing features.
• HTML 3.2 (1997): Added support for scripting and styles.
• HTML 4.01 (1999): Improved structure and multimedia support.
• XHTML 1.0 (2000): A reformulation of HTML 4.01 in XML.
• HTML5 (2014): Modern version with video/audio, APIs, semantic tags.
4. What is XHTML?
Definition:
XHTML (Extensible HyperText Markup Language) is a stricter and XML-based version
of HTML. It combines the flexibility of HTML with the rigor of XML, making web
documents more consistent and error-free.
Key Features:
• Written in well-formed XML.
• Case-sensitive tags (tags must be lowercase).
• All tags must be properly closed.
• Attribute values must be quoted.
Example of XHTML Syntax:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XHTML Example</title>
</head>
<body>
<h1>Welcome</h1>
<p>This is written in XHTML.</p>
</body>
</html>
<p> Paragraph
<a> Hyperlink
Note: In XHTML, self-closing tags (like <br>, <hr>, <img>) must be written as <br />, <hr
/>, <img />.
<font> CSS
Example:
Instead of using:
<font size="4" color="red">Hello</font>
Use:
<p style="font-size: 20px; color: red;">Hello</p>
1. Introduction
In HTML, presentational elements are used to change the look and style of the text or
content. These tags help in making the webpage look better by using bold, italic, underline,
colors, font size, and alignment.
In older versions of HTML (like HTML 3.2), these tags were commonly used. But in modern
HTML5, we use CSS (Cascading Style Sheets) to do the same work in a better way. Still,
learning presentational tags is useful for understanding the basics.
5. Preformatted Content
5.1 <pre> – Preserved Whitespace
The <pre> tag displays text exactly as typed in the code (including spaces and line breaks).
Often used for displaying code samples.
<pre>
for (int i = 0; i < 5; i++) {
cout << i;
}
</pre>
Useful and still valid in modern HTML.
c) <abbr> – Abbreviation
The <abbr> tag is used to show the short form of a word. You can use the title attribute to
show the full form when the mouse hovers over it.
<p><abbr title="World Health Organization">WHO</abbr> is a global health agency.</p>
When you move the mouse over "WHO", it will show: World Health Organization
d) <cite> – Citation or Book Title
Used to mark the title of a book, movie, or article.
<p>I read <cite>Wings of Fire</cite> by Dr. A.P.J. Abdul Kalam.</p>
It usually appears italic in the browser.
e) <dfn> – Definition
Marks the word that is being defined.
<p><dfn>HTML</dfn> stands for HyperText Markup Language.</p>
The word "HTML" is the term being defined.
i) <var> – Variable
Used to show a variable in a math or programming expression.
<p>The area of a circle is <var>πr²</var>.</p>
7. Summary
Tag Purpose
<em> Emphasis
<strong> Importance
<abbr> Abbreviation
<cite> Title of book/article
<dfn> Definition
<code> Programming code
<kbd> Keyboard input
<samp> Output sample
<var> Variable
<mark> Highlighted text
<time> Time/date info
Lists in HTML
1. Introduction to Lists
HTML provides lists to display a group of related items in a structured format. Lists are
useful for:
• Showing steps or procedures
• Creating menus
• Displaying grouped information
• Organizing content
There are three main types of lists in HTML:
1. Ordered List (<ol>)
2. Unordered List (<ul>)
3. Definition List (<dl>)
Each list type is used based on the situation or purpose of the content.
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
</dl>
Output:
HTML
HyperText Markup Language
CSS
Cascading Style Sheets
5. Nested Lists
You can nest a list inside another list, either ordered or unordered.
Example: Nested Unordered List
<ul>
<li>Fruits
<ul>
<li>Apple</li>
<li>Mango</li>
</ul>
</li>
<li>Vegetables</li>
</ul>
Output:
• Fruits
- Apple
- Mango
• Vegetables
<h2>Ordered List</h2>
<ol type="I">
<li>Login</li>
<li>Choose Products</li>
<li>Checkout</li>
</ol>
<h2>Unordered List</h2>
<ul>
<li>Pen</li>
<li>Pencil</li>
<li>Eraser</li>
</ul>
<h2>Definition List</h2>
<dl>
<dt>RAM</dt>
<dd>Random Access Memory</dd>
<dt>CPU</dt>
<dd>Central Processing Unit</dd>
</dl>
</body>
</html>
</body>
</html>
Explanation:
• <del> and <ins> show what was changed
• <mark> highlights important note
• <strong> and <em> show priority and stress
1. Introduction
HTML (HyperText Markup Language) uses elements to define the structure and content of a
web page. Each element typically includes:
• A start tag (<tagname>)
• The content
• An end tag (</tagname>)
HTML elements can also include attributes that provide additional information about an
element, usually written in the start tag.
Example:
<a href="https://example.com">Visit Example</a>
In the above:
• <a> is an element
• href="https://example.com" is an attribute
3. Structural Elements
Structural elements help organize the layout and content hierarchy of a webpage.
Common Examples:
Tag Usage
<html> Root element, encloses the entire HTML page
<head> Includes metadata, styles, scripts
<body> Contains all the content visible to the user
<title> Defines the browser title of the page
Example Structure:
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
</head>
<body>
<h1>Welcome</h1>
<p>This is a basic page.</p>
</body>
</html>
5. HTML Attributes
Attributes are used inside HTML tags to control the behavior or appearance of elements.
They are always written in the name="value" format.
General Rules:
• Written in the start tag
• Name is case-insensitive (but lowercase is recommended)
• Quotation marks are required for values
Example:
<img src="photo.jpg" alt="A photo of a sunset">
• src and alt are attributes of the <img> element
12. Summary
Core HTML elements and attributes are the foundation of every webpage. Mastering these
ensures that your web pages are:
• Well-structured
• Accessible
• SEO-friendly
• Easier to style and script
Key Takeaways:
• HTML elements define structure and content
• Attributes provide extra information
• Use semantic elements for clarity and accessibility
• Combine core elements with CSS and JavaScript for rich webpages
4. Event Attributes
Event attributes help define JavaScript-based actions that occur in response to user
interactions, such as clicking, hovering, or typing.
Mouse Events
Attribute Description
onclick Triggers when clicked
ondblclick Triggers on double click
onmouseover Triggers when hovered
onmouseout Triggers when mouse leaves
Keyboard Events
Attribute Description
onkeydown When a key is pressed down
onkeyup When a key is released
onkeypress While the key is pressed
Form Events
Attribute Description
onchange When value of input changes
onsubmit When form is submitted
onreset When form is reset
onfocus When element gets focus
onblur When element loses focus
Example:
<button onclick="alert('Clicked!')">Click Me</button>
11. Summary
Attribute groups in HTML help developers:
• Organize HTML code better
• Understand which attributes are valid for which elements
• Enhance functionality and user interactivity
• Maintain consistency and accessibility
Group Name Use Case Example
Global Used on any HTML element
Event JavaScript interactivity
Form Capturing user input
Image Adding images
Anchor Navigation and links
Media Embedding audio/video
Input Input validation and customization
2. Types of Links
There are different types of links that can be created in HTML:
Link Type Description
Absolute URL Link Links to external websites
Relative URL Link Links to internal files within the same domain
Email Link Opens the default mail client
Phone Link Initiates phone call on mobile devices
Downloadable File Link Provides direct download of a file
Bookmark Link Links to a specific part within the same web page
Example – Absolute Link:
<a href="https://www.google.com">Visit Google</a>
Example – Relative Link:
<a href="about.html">About Us</a>
9. Downloadable Links
Using the download attribute, you can provide direct download functionality.
Example:
<a href="brochure.pdf" download>Download Brochure</a>
• The download attribute tells the browser to download the file instead of opening it.
• Optional: You can specify the file name.
<a href="image.jpg" download="newimage.jpg">Download Image</a>
11. Summary
Concept Example
Basic Link <a href="url">Text</a>
New Tab target="_blank"
Email mailto:[email protected]
Telephone tel:+911234567890
Bookmark/Anchor href="#section-id"
Download File download="filename"
Image Link <a><img src="..."></a>
Understanding basic links is the foundation of web navigation. Whether linking internal
pages, external resources, or files, mastering the use of the <a> tag and its attributes ensures a
user-friendly, accessible, and efficient web experience.
1. Introduction
The <a> tag, or anchor tag, is one of the most powerful and widely used elements in HTML.
It allows you to create hyperlinks, which are fundamental to the web. By using the <a>
element, users can click text or images to navigate between webpages, download files, or
trigger communication features like emails or phone calls.
Basic Syntax:
<a href="URL">Link Text</a>
• href – the hyperlink reference (destination)
• Link Text – the clickable text visible to users
16. Summary
Feature Description
mailto: Opens default email application
subject Adds a pre-filled subject
body Adds a pre-filled message body
cc, bcc Sends copy to additional recipients
URL Encoding Required for special characters
CSS Styling Possible using attribute selectors
Security Tips Avoid exposing plain-text emails to scrapers