HTML Notes (Basic)
HTML Notes (Basic)
HTML stands for Hypertext Markup Language, and it is the most widely used
language to write Web Pages.
• Hypertext refers to the way in which Web pages (HTML documents) are
linked together. Thus, the link available on a webpage is called Hypertext.
• As its name suggests, HTML is a Markup Language which means you use
HTML to simply "mark-up" a text document with tags that tell a Web
browser how to structure it to display.
Originally, HTML was developed with the intent of defining the structure of
documents like headings, paragraphs, lists, and so forth to facilitate the sharing
of scientific information between researchers.
Now, HTML is being widely used to format web pages with the help of different
tags available in HTML language.
Features:
Platform-independent (runs on all browsers and devices).
Easy to learn and understand.
Forms the foundation of every website on the Internet.
Not case-sensitive, but lowercase tags are preferred.
Basic form
HTML 2.0 1995 elements
introduced
Tables, scripting
HTML 3.2 1997
(JavaScript)
Divs, styling
HTML 4.01 1999 support, better
structure
HTML5:
The most modern and widely-used version.
Supports multimedia content without plugins.
Mobile-friendly and responsive design support.
Backward-compatible with older HTML versions.
Setting Up the Environment
Tools Needed:
1. Text Editor
Used to write HTML code.
Basic editors: Notepad (Windows), TextEdit (Mac)
Code editors: Visual Studio Code, Sublime Text, Atom
o Syntax highlighting
o Code suggestions
2. Web Browser
Used to run and display HTML pages.
Popular options: Google Chrome, Mozilla Firefox, Microsoft Edge, Safari
6. Embedding Multimedia
HTML allows embedding of audio, video, and interactive content without
any plugins.
Example: YouTube videos embedded on blogs, background music on a webpage.
7. Educational Platforms
HTML structures the learning material on platforms like Coursera, Khan
Academy, or online coding tutorials.
Example: Coding practice windows, lessons, and quizzes are made with HTML +
CSS + JS.
Real-World Examples
3
YouTube HTML shows video player
layout, titles, and comments.
4
Structure of an HTML Document
HTML is a markup language and makes use of various tags to format the content.
These tags are enclosed within angle braces <Tag Name>. Except few tags, most
of the tags have their corresponding closing tags. For example, <html> has its
closing tag</html> and <body> tag has its closing tag </body> tag etc.
<!DOCTYPE html>
<html>
<head>
<title>My First Page</title>
</head>
<body>
<h1>Welcome to HTML!</h1>
<p>This is a basic HTML document.</p>
</body>
</html>
Tag Description
<!DOCTYPE...> This tag defines the document type and HTML version.
The <title> tag is used inside the <head> tag to mention the
<title>
document title.
5
This tag represents the document's body which keeps other
<body>
HTML tags like <h1>, <div>, <p> etc.
Explanation:
<!DOCTYPE html>: Declares the document as HTML5.
<html>: The root tag that contains all other elements.
<head>: Meta-information about the page (not visible on
the page).
<title>: Shown on the browser tab.
<body>: Contains the visible content (text, images, links,
etc.)
<body>
Document body related tags
</body>
</html>
6
The <!DOCTYPE> Declaration
The <!DOCTYPE> declaration tag is used by the web browser to understand the
version of the HTML used in the document. Current version of HTML is 5 and it
makes use of the following declaration:
<!DOCTYPE html>
There are many other declaration types which can be used in HTML document
depending on what version of HTML is being used. We will see more details on
this while discussing <!DOCTYPE...> tag along with other HTML tags.
Heading Tags
Any document starts with a heading. You can use different sizes for your
headings. HTML also has six levels of headings, which use the elements <h1>,
<h2>, <h3>, <h4>, <h5>, and <h6>. While displaying any heading, browser
adds one line before and one line after that heading.
Example
<!DOCTYPE html>
<html>
<head>
<title>Heading Example</title>
</head>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5> <h6>This is heading 6</h6>
</body>
</html>
7
Paragraph Tag
The <p> tag offers a way to structure your text into different paragraphs. Each
paragraph of text should go in between an opening <p> and a closing </p> tag
as shown below in the example:
Example
<!DOCTYPE html>
<html>
<head>
<title>Paragraph Example</title>
</head>
<body>
<p>Here is a first paragraph of text.</p>
<p>Here is a second paragraph of text.</p>
<p>Here is a third paragraph of text.</p>
</body>
</html>
Whenever you use the <br /> element, anything following it starts from the next
line. This tag is an example of an empty element, where you do not need opening
and closing tags, as there is nothing to go in between them.
The <br /> tag has a space between the characters br and the forward slash. If
you omit this space, older browsers will have trouble rendering the line break,
while if you miss the forward slash character and just use <br> it is not valid in
XHTML.
Example
<!DOCTYPE html>
<html>
<head>
<title>Line Break Example</title>
</head>
<body>
<p>Hello<br />
You delivered your assignment on time.<br />
Thanks<br />
Mahnaz</p>
</body>
</html>
Hello
You delivered your assignment on time.
Thanks
Mahnaz
Centering Content
9
You can use <center> tag to put any content in the center of the page or any
table cell.
Example
<!DOCTYPE html>
<html>
<head>
<title>Centring Content Example</title>
</head>
<body>
<p>This text is not in the center.</p>
<center>
<p>This text is in the center.</p>
</center>
</body>
</html>
Horizontal Lines
Horizontal lines are used to visually break-up sections of a document. The <hr>
tag creates a line from the current position in the document to the right margin
and breaks the line accordingly.
For example, you may want to give a line between two paragraphs as in the
given example below:
Example
<!DOCTYPE html>
<html>
<head>
10
<title>Horizontal Line Example</title>
</head>
<body>
<p>This is paragraph one and should be on top</p>
<hr />
<p>This is paragraph two and should be at bottom</p>
</body>
</html>
This will produce the following result:
Again <hr /> tag is an example of the empty element, where you do not need
opening and closing tags, as there is nothing to go in between them.
The <hr /> element has a space between the characters hr and the forward
slash. If you omit this space, older browsers will have trouble rendering the
horizontal line, while if you miss the forward slash character and just use <hr> it
is not valid in XHTML
Preserve Formatting
Sometimes, you want your text to follow the exact format of how it is written in
the HTML document. In these cases, you can use the preformatted tag <pre>.
Any text between the opening <pre> tag and the closing </pre> tag will
preserve the formatting of the source document.
Example
<!DOCTYPE html>
<html>
<head>
<title>Preserve Formatting Example</title>
</head>
11
<body>
<pre>
function
testFunction( strText )
{ alert (strText)
}
</pre>
</body>
</html>
This will produce the following result:
function testFunction( strText ){
alert (strText)
}
Try using the same code without keeping it inside <pre>...</pre> tags
Nonbreaking Spaces
Suppose you want to use the phrase "12 Angry Men." Here, you would not want a
browser to split the "12, Angry" and "Men" across two lines:
In cases, where you do not want the client browser to break text, you should use
a nonbreaking space entity instead of a normal space. For example, when
coding the "12 Angry Men" in a paragraph, you should use something similar to
the following code:
Example
<!DOCTYPE html>
<html>
<head>
<title>Nonbreaking Spaces Example</title>
</head>
12
<body>
<p>An example of this technique appears in the movie
"12 Angry Men."</p>
</body>
</html>
13
HTML – Elements
An HTML element is defined by a starting tag. If the element contains other
content, it ends with a closing tag, where the element name is preceded by a
forward slash as shown below with few tags:
<br />
It is very much allowed to keep one HTML element inside another HTML element:
Example
<!DOCTYPE html>
<html>
14
25
<head>
Formatting Tags
HTML includes tags to format text:
Example:
<!DOCTYPE html>
<html>
<head>
<title>HTML Basics</title>
</head>
<body>
</body>
</html>
Notes ignored by
Comment <!-- comment -->
browser
Text Alignment
To align text (left, center, right), use the style attribute with text-align.
<p style="text-align: left;">Left aligned</p>
<p style="text-align: center;">Center aligned</p>
<p style="text-align: right;">Right aligned</p>
🔸 text-align values: left, right, center, justify
Example:
<!DOCTYPE html>
<html>
<head>
<title>Text Formatting</title>
</head>
<body>
<h2>Text Formatting</h2>
</body>
17
</html>
Tag Purpose
<sup> Superscript
<sub> Subscript
style="font-
Font type
family"
style="font-
Font size
size"
style="text-
Text alignment
align"
18
HTML List Tags
19
An unordered list presents items with no specific order, typically marked by
bullets.
Syntax:
<ul>
<li>Milk</li>
<li>Bread</li>
<li>Butter</li>
</ul>
Output:
Milk
Bread
Butter
Optional list-style-type (using CSS):
Change bullet style:
<ul style="list-style-type: circle;"> <!-- ○ -->
<ul style="list-style-type: square;"> <!-- ■ -->
<ul style="list-style-type: none;"> <!-- no bullet -->
Use Cases:
To-do lists
Navigation menus
Features or benefits lists
20
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
</dl>
Tag Breakdown:
Tag Meaning
Starts the
<dl>
description list
Description or
<dd> definition of the
term
Use Cases:
Glossaries
FAQs
Technical specifications or product details
21
<h2>Unordered List - Grocery Items</h2>
<ul style="list-style-type: square;">
<li>Milk</li>
<li>Eggs</li>
<li>Bread</li>
</ul>
<dt>CSS</dt>
<dd>Styles the visual presentation of web pages.</dd>
<dt>JavaScript</dt>
<dd>Adds interactivity to websites.</dd>
</dl>
</body>
</html>
Summary Table
Numbered
Ordered List <ol> <li>
list
Unordered
<ul> <li> Bulleted list
List
22
23
Anchor Tags & Hyperlinks in HTML
What is a Hyperlink?
A hyperlink is a clickable element (usually text or image) that redirects users to
another web page, section, or resource.
The HTML tag used to create hyperlinks is:
<a href="URL">Link Text</a>
What is a Hyperlink?
A hyperlink is a clickable element (usually text or image) that redirects users to
another web page, section, or resource.
The HTML tag used to create hyperlinks is:
<a href="URL">Link Text</a>
2. External Links
Definition:
An external link directs the user to a different website or domain.
🔸 Syntax:
<a href="https://www.google.com" target="_blank">Visit Google</a>
25
Attribute Use
Example:
<a href="https://www.wikipedia.org" target="_blank" title="Go to
Wikipedia">Wikipedia</a>
Useful for:
Referencing other websites
Linking to external blogs, videos, documentation
Citing sources
Use the target attribute to define where to open the linked document
Complete Example:
<!DOCTYPE html>
<html>
<head>
<title>Link Demo</title>
</head>
<body>
<h1>Welcome to My Page</h1>
<hr>
</body>
</html>
Summary Table
"about.html" or
href example "https://example.com"
"#section1"
Referencing external
Use case Navigation, page jump
content
Assignment
1. HTML Page Setup
Create a file named profile.html
Add the standard HTML5 structure:
27
o <!DOCTYPE html>
3. Text Formatting
Use the following tags at least once:
<b>, <i>, <u>
<sup>, <sub>
Use inline styles to center align or right align a paragraph.
4. Lists
Include the following:
An ordered list for your daily routine or study plan
An unordered list for your favorite books or subjects
A description list for explaining 3 tech terms (e.g., HTML, CSS, JS)
5. Hyperlinks
Add one internal link to jump to a section within the same page.
Add one external link to your favorite website using:
<a href="https://example.com" target="_blank" title="Visit
Example">Example</a>
6. Comments
Add comments in your code to label major sections:
<!-- This is the About Me section -->
7. Background Style
28
Use inline style in the <body> tag to set:
o A background color (e.g., lightblue or beige)
o Text color
o Font family
29
HTML Tables
Basic Table Tags
Tag Purpose
Starts the
<table>
table
Table data
<td>
(cell)
Table header
<th>
cell
Table header
<thead>
section
Table body
<tbody>
section
Table footer
<tfoot>
section
Merge
colspan
columns
30
<tr>
<td>Science</td>
<td>85</td>
</tr>
</table>
Output:
Subjec
Marks
t
Math 90
Scienc
85
e
Tag-wise Explanation
<table>
Wraps the entire table.
<tr> (Table Row)
Defines a row in the table.
<th> (Table Header Cell)
Used inside a <tr> to make the heading bold and centered by default.
<td> (Table Data Cell)
Represents actual data in each cell.
Ex - Student Marksheet
<h2>Student Marksheet</h2>
<table border="1" cellpadding="8" cellspacing="0">
<tr>
<th>Roll No</th>
<th>Name</th>
<th>Math</th>
<th>Science</th>
<th>Total</th>
</tr>
<tr>
<td>101</td>
<td>Amit</td>
<td>80</td>
<td>90</td>
<td>170</td>
</tr>
<tr>
<td>102</td>
<td>Sara</td>
<td>85</td>
<td>95</td>
<td>180</td>
</tr>
</table>
32
Summary Table of Tags
Tag Description
Creates a
<tr>
table row
Table data
<td>
(cell)
Table header
<thead>
group
Table body
<tbody>
group
Table footer
<tfoot>
group
Merge
colspan
columns
33
HTML Multimedia Elements
1. Adding Images with <img> Tag
Syntax:
<img src="image.jpg" alt="Description" width="300" height="200">
Attributes:
Attribute Description
Example:
<img src="cat.jpg" alt="A cute cat" width="250" height="200">
Attribute Description
Plays video
autoplay
automatically
Example:
<video width="300" controls poster="thumbnail.jpg">
<source src="demo.mp4" type="video/mp4">
Your browser doesn't support the video tag.
</video>
3. Embedding Audio
The <audio> tag is used to add music or audio clips.
Syntax:
<audio controls>
<source src="audio.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
Common Audio Types:
audio/mpeg (MP3)
audio/ogg
audio/wav
Example:
<audio controls>
<source src="music.mp3" type="audio/mpeg">
Your browser does not support audio playback.
</audio>
src, controls,
<video> Embed videos
autoplay, loop, poster
src, controls,
<audio> Embed sound
autoplay, loop
Mini Practice:
<h2>My Favorite Song</h2>
<audio controls>
<source src="mysong.mp3" type="audio/mpeg">
</audio>
<h2>My Pet</h2>
<img src="dog.jpg" alt="A cute dog" width="300">
36
HTML Forms and Input Elements
1. Creating Forms with <form>
Basic Syntax:
<form action="submit.php" method="post">
<!-- form elements go here -->
</form>
Attribute Description
Limited to ~2048
No limit (can send large
Data Limit characters (depends on
data like files)
browser)
37
Which to Use?
Use GET for search, filters, or navigation
Use POST for login, signup, or confidential data
2. Input Types
<form>
<input type="text" name="username" placeholder="Enter your name"><br>
Type Purpose
Choose one
radio
from group
38
Select multiple
checkbox
options
Select Dropdown:
<label for="city">City:</label>
<select name="city" id="city">
<option value="mumbai">Mumbai</option>
<option value="delhi">Delhi</option>
<option value="pune">Pune</option>
</select>
Textarea:
<label for="msg">Message:</label><br>
<textarea id="msg" name="message" rows="4" cols="30">Enter your message
here...</textarea>
4. Buttons and Submission
Submit Button:
<input type="submit" value="Submit">
Reset Button:
<input type="reset" value="Clear Form">
Regular Button:
<button type="button" onclick="alert('Clicked!')">Click Me</button>
39
Example: Complete Form
<form action="submit.php" method="post">
<label for="name">Name:</label><br>
<input type="text" id="name" name="name"><br><br>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email"><br><br>
Gender:<br>
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female<br><br>
Hobbies:<br>
<input type="checkbox" name="hobby" value="reading"> Reading
<input type="checkbox" name="hobby" value="sports"> Sports<br><br>
<label for="city">City:</label><br>
<select name="city" id="city">
<option value="mumbai">Mumbai</option>
<option value="delhi">Delhi</option>
</select><br><br>
<label for="msg">Message:</label><br>
<textarea id="msg" name="message" rows="4"
cols="40"></textarea><br><br>
40
HTML Forms Assignment
Create a Student Registration Form using HTML with the following
components:
Form Requirements:
1. Form Attributes:
o action="#" (no actual submission needed)
o method="post"
2. Input Fields:
o Full Name (Text)
o Email (Email)
o Password (Password)
3. Dropdown List:
o Choose your City: (Mumbai, Delhi, Pune, Bangalore)
4. Textarea:
o Write a short Bio/About Yourself
5. Buttons:
o Submit
o Reset
41