Chapter 2 - HTML
Chapter 2 - HTML
ABSTRACT
HTML is the foundation of web
development, used to structure
and present content on the web.
This module introduces the basics
of HTML page structure, core tags,
and editors, followed by semantic
and non-semantic elements,
document structure, layout, text,
and formatting tags. Learners will
gain a strong foundation for
creating well-structured and
HTML Structure and Core Tags
meaningful web pages.
Learn to structure the web with HTML.
[Date]
1
HTML Structure and Core Tags
❖ Basics of HTML
✓ HTML stands for Hyper Text Markup Language
✓ It is used to design the web pages.
✓ With the help of HTML, you can create a complete website structure.
✓ HTML is the combination of Hypertext and Markup language. Hypertext defines the link between the
web pages and markup language defines the text document within the tag that define the structure of
web pages.
✓ HTML consists of a series of elements
✓ HTML elements tell the browser how to display the content
HTML Tags: Tags are the starting and ending parts of an HTML element. They begin with < symbol and
end with > symbol. Whatever written inside < and > are called tags.
HTML elements: Elements enclose the contents in between the tags. They consist of some kind of
structure or expression. It generally consists of a start tag, content and an end tag.
Where, <b> is the starting tag and </b> is the ending tag.
HTML Attributes: It is used to define the character of an HTML element. It always placed in the opening
tag of an element. It generally provides additional styling (attribute) to the element.
[Date]
2
HTML Structure and Core Tags
❖ Page Structure
[Date]
3
HTML Structure and Core Tags
❖ Editors
Web pages can be created and modified by
using editors (sublime,notepad++,vs code etc).
However, for learning HTML it is recommended
to use simple text editor like Notepad/TextEdit
(Mac). It is good way to learn HTML.
First Example:
❖ Open Notepad
❖ Write HTML
<!DOCTYPE html>
<html>
<head><title>Test</title></head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
❖ Save the HTML Page
Save the file on your computer. Select File > Save as in the Notepad menu. Name the file "index.html"
or “index.htm”
❖ View the HTML Page in Your Browser
Open the saved HTML file in your favorite browser (double click on the file, or right-click - and choose
"Open with").
The result will look much like this:
[Date]
4
HTML Structure and Core Tags
❖ HTML Comments
• In HTML, comments are written using <!-- and -->.
• The browser ignores everything inside the comment.
• Comments are useful to explain code, organize sections, or hide code for testing
Syntax:
<!-- This is a comment -->
Example:
<!DOCTYPE html>
<html>
<head>
<!-- This is the head section -->
<title>My First Webpage</title>
</head>
<body>
<!-- Main heading -->
<h1>Welcome</h1>
</body>
</html>
[Date]
5
HTML Structure and Core Tags
• Semantic Tags → clearly describe their meaning and purpose both to the browser and
developer. They make code more readable, SEO-friendly, and accessible.
o Examples:
▪ <header> → defines header section
▪ <footer> → defines footer section
▪ <article> → represents an independent article
▪ <section> → defines a thematic section
▪ <aside> → tangential/side content (ads, related links, tips)
▪ <nav> → navigation links
▪ <main> → main content area
• Non-Semantic Tags → do not describe their meaning. They are used mainly for styling or
grouping. They don’t tell what the content is, only how it should look.
o Examples:
▪ <div> → division/container
▪ <span> → inline container for text [Date]
6
HTML Structure and Core Tags
Inline Elements
Inline elements do not start on a new line. They only take up as much width as their content requires.
They are often used for formatting, styling, or embedding small chunks of content within block
elements.
<a>, <span>, <b>, <strong>, <i>, <em>, <img>, <br>, <label>, <input>, <textarea>, <select>,<button>,
<sub>, <sup>, <abbr>
[Date]
7
HTML Structure and Core Tags
<!DOCTYPE html>
<html>
<head>
<title>Head Tags Example</title>
<!-- Link tag: external CSS file and favicon -->
<link rel="stylesheet" href="styles.css">
<link rel="icon" type="image/png" href="favicon.png">
<!-- Style tag: internal CSS -->
<style>h1 { color: blue; }</style>
<!-- Script tag: external JavaScript -->
<script src="s1.js"></script>
</head>
<body><h1>Head Tags Demonstration</h1></body>
</html>
8
HTML Structure and Core Tags
2. viewport
Purpose: Makes a website responsive on mobile devices.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Example: Flipkart or Myntra: On a mobile phone, the layout adjusts so product images, buttons, and
menus fit perfectly, making online shopping easy on smartphones.
3. description
Purpose: Short summary of the page, used by search engines.
<meta name="description" content="Learn the best street food recipes from India including
chaat, vada pav, and golgappa.">
Example: When someone searches “Indian street food recipes,” Google may show this description
under the page title on Sanjeev Kapoor’s recipe website or Tarla Dalal recipes.
4. keywords
Purpose: List of keywords relevant to the page content.
<meta name="keywords" content="Indian recipes, street food, vada pav, chaat, golgappa">
Example: Helps search engines understand the page topic. For instance, a blog about Indian street
food will rank better when users search for “vada pav recipe” or “chaat recipes.”
5. author
Purpose: Indicates the creator of the webpage.
<meta name="author" content="Arjun Mehta">
Example: A food blog post written by Arjun Mehta, an Indian food blogger. Some browsers or CMS
platforms may display the author’s name, giving proper credit.
6. http-equiv
Purpose: Provides HTTP header-like info. Can be used for refresh, content type, or caching.
<meta http-equiv="refresh" content="10;url=https://indiatimes.com">
Example: A page on IndiaTimes that says “Thank you for subscribing to our newsletter” and then
redirects to the homepage after 10 seconds.
Example:
<head>
<!-- Character encoding for Indian languages -->
<meta charset="UTF-8">
<!-- Responsive design for mobile devices -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Short description for search engines -->
<meta name="description" content="Explore the best Indian street food recipes including chaat,
[Date]
[Date]
10
HTML Structure and Core Tags
❖ TAGS
Category Tag Description
Layout & Sectioning Tags <div> Generic container, used for grouping elements.
Inline container for styling a small portion of
<span>
text.
Represents the top section of a webpage or
<header>
article.
Bottom section of a webpage (credits,
<footer>
copyright).
<main> Main content of the webpage.
<section> Defines sections in a webpage.
Represents self-contained content (e.g., blog
<article>
post).
<aside> Sidebar content, not the main focus.
<nav> Navigation links/menu.
Content & Text Tags <h1> to <h6> Headings (h1 is largest, h6 is smallest).
<p> Paragraph of text.
Preformatted text (preserves spaces, line
<pre>
breaks).
<br> Line break.
<hr> Horizontal line (divider).
Hyperlink Tag <a> Anchor tag used for hyperlinks.
Text Formatting Tags <b> Bold text (visual only).
<strong> Important text (semantic meaning).
<i> Italic text (visual only).
<em> Emphasized text (semantic meaning).
<u> Underlined text.
<mark> Highlighted text.
<del> Deleted/strikethrough text.
<ins> Inserted/underlined text.
<sub> Subscript (below text).
<sup> Superscript (above text).
<abbr> Abbreviation (shows full form on hover).
Example:
[Date]
<html>
<head>
11
HTML Structure and Core Tags
<section>
<article>
<h1>Main Heading</h1>
<p>This is a <b>bold</b> word and this is <i>italic</i>.</p>
<p>You can also <strong>highlight importance</strong> or <em>emphasize
text</em>.</p>
<p>
Here is <u>underlined</u>, <mark>highlighted</mark>, <del>deleted</del>,
and <ins>inserted</ins> text.
</p>
<p>Water formula: H<sub>2</sub>O and Square: x<sup>2</sup></p>
<p>
<abbr title="HyperText Markup Language">HTML</abbr> is the base of web
pages.
</p>
<pre>
Preformatted text keeps
spaces & line breaks.
</pre>
<p>Line break here<br>Next line</p>
<hr>
<a href="https://example.com" target="_blank">Visit Example.com</a>
</article>
</section>
<aside>Sidebar Information</aside>
</main>
<footer>Website Footer</footer>
</body>
</html>
[Date]
12
HTML Structure and Core Tags
Output:
13
HTML Structure and Core Tags
Attributes:
Example:
<a href=”https://www.example.com” target=”_blank”>Click here</a>
Example: Create a webpage that contains a long block of text and a link at the bottom which, when
clicked, scrolls the user back to the top of the page. The solution should demonstrate how to use the id
attribute to define an anchor point (<a id="...">) and the href="#..." link to navigate back to that point.
<html>
<body>
<a id="test"></a>
<h1>
<pre>
a
[Date]
b
c
14
HTML Structure and Core Tags
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
a
b
c
d
e
f
g
h
i
j
</pre>
</h1>
<a href="#test">Scroll to top</a>
</body>
</html>
[Date]
1. <a id="test"></a>: A unique identifier used to reference or target elements. It is the preferred method
in modern HTML. Using id is more current and widely supported.
15
HTML Structure and Core Tags
This creates a hyperlink that, when clicked, will scroll the user back to the point in the page where the
named anchor (<a name="test"></a>) is located. The #test in the href attribute reference.
Note:
name: Used in older versions of HTML for named anchors, but mostly for form elements now. It's
deprecated for anchor elements in HTML5.
[Date]
16
HTML Structure and Core Tags
❖ Media Tags
<img>
• Used to display images.
• Attributes: src (image source), alt (alternative text), width, height.
<figure>
<img src="html.jpg" alt="A beautiful image" width="300" height="200">
<figcaption>Html Image</figcaption>
</figure>
Using <figure> with <img> is useful because it semantically groups an image with its caption,
making the content more meaningful and accessible. The <figcaption> inside <figure> provides a clear
description or context for the image, which improves accessibility, SEO, and content clarity.
[Date]
17
HTML Structure and Core Tags
Information:
<audio>
• Embeds audio files.
• Attributes: controls (show play/pause controls), autoplay, loop, muted.
o controls → shows play/pause/volume UI.
o autoplay → tries to start audio automatically.
o muted → starts muted (browsers allow muted autoplay).
o loop → plays continuously.
Example:
<audio controls autoplay muted loop>
<source src="1.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<video>
• Embeds video files.
• Attributes: controls, autoplay, loop, width, height, muted.
Example:
<video autoplay controls muted loop width="700" height="500">
<source src="2.mp4" type="video/mp4" >
Your browser does not support the video element.
</video>
[Date]
18
HTML Structure and Core Tags
<source>
• Specifies multiple media sources for <audio> or <video> so the browser can choose a
supported format.
Example:
<video width="400" controls>
<source src="video.mp4" type="video/mp4">
<source src="video.ogg" type="video/ogg">
</video>
[Date]
19
HTML Structure and Core Tags
<iframe>
• Embeds another webpage, map, video (like YouTube), pdf etc inside your page.
Attribute Purpose Example from your code
src URL or file path of embedded resource src="https://www.wikipedia.org"
width Sets width in pixels width="600"
height Sets height in pixels height="400"
frameborder Shows/hides border (deprecated) frameborder="0"
style Inline CSS (styling) style="border:0;"
allowfullscreen Allows fullscreen (mainly for video) allowfullscreen (YouTube iframe)
loading Lazy/eager load for performance loading="lazy" (Google Maps iframe)
title Accessibility/SEO description title="YouTube video player"
Example:
<body>
<h1>Iframe Examples</h1>
20
HTML Structure and Core Tags
</body>
[Date]
21
HTML Structure and Core Tags
❖ HTML Lists:
A list is a record of short pieces of related information or used to display the data or any
information on web pages in the ordered or unordered form. For instance, to purchase the items,
we need to prepare a list that can either be ordered or unorderedlist which helps us to organize
the data & easy to find the item.
<ul> Output:
<li>Test 1</li>
<li>Test 2</li>
<ul type="square">
<li>Test 3</li>
<li>Test 4</li>
</ul>
</ul>
type="disc":
Items are marked with filled circles as bullet points. This
is default.
● Item 1
● Item 2
● Item 3
type="square":
Items are marked with squares.
■ Item 1
■ Item 2
■ Item 3
type="circle":
Items are marked with hollow circles.
Item 1
Item 2
Item 3
type="none":
No bullet points are shown for the list items.
Item 1
Item 2
Item 3
[Date]
22
HTML Structure and Core Tags
2. Ordered list: An ordered list starts with the <ol> tag. Each list item startswith the <li> tag.
The list items will be marked with numbers by default:
Attribute:
type: type=” 1/ i/ I/ a/ A”
start: Specifies the start value of an ordered list
reversed: Specifies that the list order should be reversed (9,8,7...)
<ol start="5">
<li>Test 1</li>
<li>Test 2</li>
<li>Test 3</li>
<ol type="A">
<li>Test 4</li>
<li>Test 5</li>
<ol reversed type="i">
<li>Test 6</li>
<li>Test 6</li>
</ol>
</ol>
</ol>
Output:
[Date]
23
HTML Structure and Core Tags
<html>
<head><title>Nested List</title></head>
<body>
<ol type="A" start="4">
<li>List1</li>
<li>List2</li>
<ul type="square">
<li>list2.1</li>
<li>list2.2</li>
<ol type="I" reversed >
<li>list 2.2.1</li>
<li>list 2.2.1</li>
<li>list 2.2.1</li>
</ol>
</ul>
<li>List3</li>
<ul type="none">
<li>list 3.1</li>
<li>list 3.2</li>
</ul>
<li>list4</li>
<ol type="a">
<li>list 4.1</li>
<ul type="circle">
<li>list 4.1.1</li>
<li>list 4.1.2</li>
</ul>
<li>list 4.1</li>
</ol>
</ol>
</body>
</html>
[Date]
24
HTML Structure and Core Tags
❖ HTML Table:
✓ The <table> tag defines HTML table.
✓ An HTML table consists of one <table> element and one or more <tr>,
<th>, and <td> elements.
✓ The <tr> element defines a table row, the <th> element defines a table header,
and the <td> element defines a table cell.
✓ An HTML table may also include <caption>
✓ , <thead>, <tfoot>, and <tbody> elements.
colorname
25
HTML Structure and Core Tags
rules none groups rows cols all Deprecated − The HTML <table> rules Attribute is
used to specify which parts of the inside borders that
should be visible.
Syntax:
<table rules="value">
Attribute Values:
• none: It does not create any lines.
• groups: It create lines between row and column
groups.
• rows: It creates line between the rows.
• cols: It creates line between the columns.
• all: It creates line between the rows and columns.
Note: The <table> rules Attribute is not supported by
HTML 5.
colorname
26
HTML Structure and Core Tags
Example 1:
<td>50</td>
</tr>
27
HTML Structure and Core Tags
</tfoot>
</table>
Example 2
Example3:
28
HTML Structure and Core Tags
Example 4
<!DOCTYPE html>
<html>
<head>
<title>Deprecated Table Attributes Example</title>
</head>
<body>
<tr bgcolor="lightblue">
<th align="left" colspan="2">Header spanning 2 columns</th>
<th rowspan="2" bgcolor="lightyellow">Rowspan Header</th>
</tr>
<tr bgcolor="lightpink">
<td align="center">Cell 1</td>
<td align="right">Cell 2</td>
</tr>
<tr bgcolor="gray">
<td>Row 2, Col 1</td>
<td colspan="2" align="justify">Merged across 2 columns</td>
</tr>
</table>
</body>
</html>
✓ If you want visible grid lines → use rules="all" and set cellspacing="0".
✓ If you want spacing between cells → use cellspacing, but then the effect of rules is lost.
[Date]
Example 5
29
HTML Structure and Core Tags
<html>
<head><title> Table </title></head>
<body align='center'>
<table border='3px' width='50%' align="center" cellpadding='15' cellspacing="5">
<caption><strong><font size="6"> Table</font></strong></caption>
<tr>
<td rowspan='2' bgcolor="yellow"> A</td>
<td bgcolor="lightgreen"> <b>B</b> </td>
<td rowspan='3' bgcolor="yellow"> D </td>
<td colspan='2' bgcolor="pink"> E </td>
<td bgcolor="lightblue"> F </td>
</tr>
<tr>
<td bgcolor="lightblue"> C </td>
<td rowspan='2' bgcolor="lightblue"> G </td>
<td rowspan='2' bgcolor="lightgreen"> <b>H</b> </td>
<td rowspan='2' bgcolor="yellow"> I </td>
</tr>
<tr>
<td colspan='2' bgcolor="pink"> J </td>
</tr>
<tr>
<td colspan='3' bgcolor="lightgreen"> <b>K</b> </td>
<td bgcolor="yellow"> L </td>
<td colspan='2' bgcolor="pink"> M </td>
</tr>
</table>
</body></html>
[Date]
Example 6
30
HTML Structure and Core Tags
Design an HTML table for LJ University - Student List that displays the Branch, Student Name, and
Roll Number of students.
The table should:
1. Use the rules="groups" attribute so that horizontal lines are drawn only between row groups
(different branches).
2. Include at least two different branches (e.g., Computer Science, Mechanical).
3. Each branch should have multiple students, and the branch name should span multiple rows
using the rowspan attribute.
4. Add a table header (<thead>) with column titles (Branch, Student Name, Roll Number).
5. Add a footer row (<tfoot>) with copyright information for LJ University.
6. Show background color for different row groups (<tbody>) so that each branch is visually distinct.
<!DOCTYPE html>
<html>
<head>
<title>College Table - Rules Groups Example</title>
</head>
<body>
<thead bgcolor="#ddd">
<tr>
<th>Branch</th>
<th>Student Name</th>
<th>Roll Number</th>
</tr>
</thead>
<tbody bgcolor="lightblue">
<tr>
<td rowspan="3">Computer Science</td>
<td>Rahul Sharma</td>
<td>CS101</td>
</tr>
<tr>
<td>Priya Patel</td>
<td>CS102</td>
</tr>
<tr>
<td>Amit Verma</td>
[Date]
<td>CS103</td>
</tr>
31
HTML Structure and Core Tags
</tbody>
<tbody bgcolor="lightyellow">
<tr>
<td rowspan="3">Mechanical</td>
<td>Rohan Mehta</td>
<td>ME201</td>
</tr>
<tr>
<td>Sneha Iyer</td>
<td>ME202</td>
</tr>
<tr>
<td>Vikas Sharma</td>
<td>ME203</td>
</tr>
</tbody>
<tfoot bgcolor="#ddd">
<tr>
<td colspan="3" align="center">LJ University © 2025</td>
</tr>
</tfoot>
</table>
</body>
</html>
[Date]
32