HTML Notes
HTML Notes
4. Link & Script Tags - 7 10. Core Web Vitals - 18 16. Semantic Tags - 29
5. Image Tags - 8 11. Forms and Input Tags - 20 17. Entities Tags - 31
Chapter 1 - Introduction
HTML (HyperText Markup Language) was created by Tim Berners-Lee in 1991 as a
standard for creating web pages. It's a markup language used to structure content
on the web, defining elements like headings, paragraphs, links, and images. HTML
forms the backbone of web content. In layman's terms, HTML is like the skeleton
of a website. It's a set of instructions that tells a web browser how to display text,
images, videos, and other elements on a webpage. Think of it as the building
blocks that create the structure and look of a website, similar to how bricks and
mortar are used to build a house.
In a nutshell:
HTML defines the barebone structure or layout of web pages that we see on
the Internet.
HTML consists of a set of tags contained within an HTML document, and the
associated files typically have either a ".html" or ".htm" extension.
There are several versions of HTML, with HTML5 being the most recent
version.
→ Features of HTML
Lessons 1
It is platform-independent. For example, Chrome displays the same pages
identically across different operating systems such as Mac, Linux, and
Windows.
Images, videos, and audio can be added to a web page (For example -
YouTube shows videos on their website)
It can be integrated with other languages like CSS, JavaScript, etc. to show
interactive (or dynamic) web pages
→DOCTYPE Declaration
<!DOCTYPE html>
The <!DOCTYPE html> declaration informs the web browser about the HTML version
being used. The latest version is HTML5. But if this changes in the future (maybe
10 years down the line), the doctype declaration will be helpful!
Lessons 2
<html>
The <html> tag is the root element that encapsulates all the content on the page.
</html>
→Head Section
<head>
The <head> tag contains metadata and links to external resources like CSS and
JavaScript files.
</head>
→Title Tag
<title>Document</title>
The <title> tag sets the title of the web page, which is displayed in the browser's
title bar or tab.
→ Body Tag
<body>
The <body> tag contains the visible content of the web page. This is where text,
images, and other elements go.
</body>
Lessons 3
The </body> tag marks the end of the visible content of the web page.
Every HTML page should include at least these essential elements to define the
basic layout. In upcoming tutorials, we'll dive deeper into the fascinating world of
HTML.
→ Summary
The <!DOCTYPE html> tag specifies that the document is an HTML5 document.
The <head> section contains metadata and the title of the webpage, which
appears in the browser's title bar.
The <body> section contains the content that will be displayed on the webpage.
The h1 and p are two types of tags. We will learn about more tags in the later
section
An HTML tag acts as a container for content or other HTML tags. Tags are words
enclosed within < and > angle brackets.
They serve as keywords that instruct the web browser on how to format and
display the content.
Lessons 4
3. <head> : Contains meta-information and links to scripts and stylesheets.
Metadata Tags
1. <title> : Sets the title of the web page.
List Tags
1. <ul> : Unordered list.
2. <img> : Image.
Form Tags
Lessons 5
1. <form> : Form.
4. <button> : Button.
Table Tags
1. <table> : Table.
Semantic Tags
1. <header> : Header section.
3. <article> : Article.
4. <section> : Section.
5. <nav> : Navigation.
Lessons 6
1. Paired Tags (Container Tags)
These are tags that come in pairs, consisting of an opening tag and a
corresponding closing tag. The content goes between these two tags.
Opening Tag: The opening tag starts with < and ends with > . For
example, <p> .
Closing Tag: The closing tag also starts with < but includes a forward
slash / before the tag name, and ends with > . For example, </p> .
Examples:
Paragraphs: <p>This is a paragraph.</p>
Self-Closing Tag: A self-closing tag starts with < and ends with /> (though
the / is optional in HTML5). For example, <img /> or <br> .
Note: Later if you happen to use react or a framework like Next.js, you will have to
close the tag like this <br/> <hr/> . So it is better to cultivate the habit!
Lessons 7
→The <link> Tag
The <link> tag is commonly used to link external stylesheets to an HTML
document. It's a self-closing tag, meaning it doesn't require a closing tag.
Below is an example HTML code snippet that includes a <link> tag to link an
external stylesheet:
Lessons 8
Commonly used attributes include the "alt" attribute for image descriptions
and the "src" attribute for specifying the image location.
Supports various image formats including PNG, JPEG, JPG, and GIF.
Note: To find the image's location, right-click on the image, go to properties, and
check the location field.
Setting the width and height attributes for images in HTML can have a positive
impact on Search Engine Optimization (SEO). Specifying these dimensions in
the <img> tag allows browsers to allocate the correct amount of space on a web
page even before the image is fully loaded. This prevents layout shifts, improving
the Cumulative Layout Shift (CLS) score—a key metric in Google's Core Web
Vitals. A better CLS score can lead to a higher page ranking in search engine
results.
Note: Styling dimensions and other properties are now more commonly managed
through CSS for better flexibility and maintainability.
Lessons 9
Chapter 6 - Pre Tag
The <pre> tag serves as an indispensable tool in HTML for displaying
preformatted text, such as code snippets in various programming languages.
<pre>
<!-- code snippet in any programming language -->
</pre>
Python Program
<pre>
# A simple Python program to print "Hello, World!"
def main():
print("Hello, World!")
if __name__ == "__main__":
main()
</pre>
Program Output
This HTML code will display the program exactly as it is, preserving spaces and
new lines. We'll use the <pre> tag to achieve this 'preformatted' display, as shown
Lessons 10
below.
if __name__ == "__main__":
main()
Lessons 11
→Target Attribute Values
_blank: Opens the linked document in a new window or tab.
Chapter 8 - List
Our day-to-day lives often involve the use of lists. For example, when we go
shopping, the bill we receive includes a list of all the items we've purchased. In a
similar manner, web developers use lists to neatly display data on websites.
Lessons 12
<ul>
<li>Pen</li>
<li>Pencil</li>
<li>Eraser</li>
</ul>
Output:
Pen
Pencil
Eraser
square
circle
<ul type="square">
<li>Notebook</li>
<li>Marker</li>
</ul>
Lessons 13
Basic Example
<ol>
<li>Mango</li>
<li>Orange</li>
<li>Litchi</li>
</ol>
Output:
1. Mango
2. Orange
3. Litchi
3. Arabic Numerals: Use type="1" (This is the default if the type attribute is not
specified)
Output:
Lessons 14
3. Pen
4. Pencil
Lessons 15
<dd>Cascading Style Sheets: A stylesheet language used f
or describing the .</dd>
<dt>JavaScript</dt>
<dd>A programming language commonly used in web developm
ent to add features.</dd>
</dl>
Chapter 9 - Table
HTML tables allow you to arrange data like text, images, and links in rows and
columns. You use the <table> tag to start and end a table.
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Harry</td>
<td>100</td>
</tr>
</table>
Lessons 16
Rowspan: If you want a table cell to span multiple rows, you can use
the rowspan attribute.
<td rowspan="value">
Colspan: If you want a table cell to span multiple columns, you can use
the colspan attribute.
<td colspan="value">
→Adding a Caption
To add a title to your table, you can use the <caption> element. This element helps
both in terms of SEO and accessibility.
<table>
<caption>Student Details</caption>
<!-- Rest of the table here -->
</table>
Lessons 17
<table>
<thead>
</thead>
<tfoot>
</tfoot>
<tbody>
</tbody>
</table>
→Column Groups
You can use the <colgroup> and <col> elements to apply styles to an entire column
in an HTML table.
<table>
<colgroup>
<col style="background-color:yellow">
</colgroup>
<!-- rest of the table -->
</table>
The metrics that make up Core Web Vitals will evolve over time. The current set
for 2020 focuses on three aspects of the user experience—loading, interactivity,
and visual stability—and includes the following metrics (and their respective
thresholds):
Lessons 18
Largest Contentful Paint (LCP): measures loading performance. To provide a
good user experience, LCP should occur within 2.5 seconds of when the page
first starts loading.
To ensure you're hitting the recommended target for these metrics for most of
your users, a good threshold to measure is the 75th percentile of page loads,
segmented across mobile and desktop devices.
Tools that assess Core Web Vitals compliance should consider a page passing if it
meets the recommended targets at the 75th percentile for all three of the Core
Web Vitals metrics.
Lessons 19
Chapter 11 - Forms and Input Tags
→Input Types
Input types in HTML forms are the backbone of interactive web applications. They
allow users to send information to web servers for various purposes like
searching, logging in, or providing feedback. In this blog, we'll explore common
HTML input types: text, password, radio, and checkbox.
→Text Input
The text input type is the most basic form of input and is widely used for
collecting simple text data.
In the above example, the placeholder attribute provides a hint to the user about
what to enter.
→Password Input
The password input type is similar to the text type but hides the characters
entered by the user for security reasons.
→Radio Buttons
Radio buttons are used when you want the user to select only one option from a
set of choices.
→Note
if we want that user can only choose one of the radio button , then we have to
put the same word in the name tag .
Lessons 20
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label>
→Checkbox
Checkboxes allow the user to select multiple options from a set.
Represents a button that, when pressed, resets all the form controls to
reset
their initial values.
datetime-local Allows the user to select a date and time with no time zone.
file Allows the user to select one or more files from their device storage.
Lessons 21
hidden Represents a value that is not displayed but is submitted to the server.
The rows and cols attributes define the visible dimensions of the textarea.
<select name="fruits">
<option value="apple">Apple</option>
<option value="banana">Banana</option>
<option value="cherry">Cherry</option>
</select>
Each option inside the select tag represents an item in the dropdown list.
Lessons 22
→action
The action attribute specifies the URL where the form data should be sent after
submission.
→method
The method attribute defines how data is sent. The two most common methods
are GET and POST .
→placeholder
This attribute provides a hint to the user as to what can be entered in the field.
→required
The required attribute makes a field mandatory to fill out.
→pattern
The pattern attribute specifies a regular expression that the input must match to
be valid.
Lessons 23
HTML offers multiple ways to select and style elements. Two of the most
commonly used selectors are IDs and Classes. This blog explores what they are,
how to use them, and their differences.
→What is an ID?
An ID is an attribute, a unique identifier assigned to only one HTML element within
a page. It is often used for unique styling and JavaScript manipulations.
<!DOCTYPE html>
<html>
<head>
Lessons 24
<style>
p {
color: blue;
font-size: 18px;
}
</style>
</head>
/* CSS for ID */
#myUniqueID {
background-color: yellow;
}
Styling: Both can be used for styling, but IDs have higher specificity.
Lessons 25
→The <video> Tag
The <video> tag is used to embed video files in an HTML document. It supports
multiple attributes to control the video playback.
Example usage:
autoplay: Automatically starts playing the video when the page loads.
→ Tip - if video does not autoplay then we have to mute the video for playing .
autoplay: Automatically starts playing the audio when the page loads.
Lessons 26
loop: Repeats the audio once it ends.
preload: Specifies if and how the audio should be loaded when the page loads
('auto', 'metadata', 'none').
Chapter 14 - I Frames
An iFrame is an HTML element that enables an inline frame for the embedding of
external content. Essentially, you can load another web page within a designated
area of your current webpage.
→Basic Syntax
The basic syntax of an iFrame is quite straightforward:
→Attributes of iFrame
Several attributes can enhance the functionality of an iFrame:
→Practical Examples
Embedding a YouTube Video
Lessons 27
<iframe src="https://www.youtube.com/embed/VIDEO_ID" framebor
der="0" allowfullscreen></iframe>
<iframe src="https://maps.google.com/maps?q=LOCATION&output=e
mbed" frameborder="0"></iframe>
Chapter 15 - SVG
SVG stands for Scalable Vector Graphics. Unlike raster images like PNGs or JPGs,
SVGs are not pixel-based. They're composed of vectors—mathematical formulas
that describe shapes, paths, and fills. This means SVGs can be resized without
losing quality.
→Note
if we want to show svg file through the image tag , then we have to add a attribute
in the svg tag into the .svg file . Attribute → xmlns="http://www.w3.org/2000/svg"
1. Inline SVG: Directly writing the SVG XML code within HTML.
Lessons 28
width="3" fill="red" />
</svg>
.background {
background-image: url('image.svg');
}
→SVG Attributes
SVG comes with a set of attributes to control its behavior:
1. <header> : Used to represent the top section of a web page, often containing
headings, logos, and navigation.
Lessons 29
4. <section> : Represents a thematic grouping of content on a web page.
Lessons 30
Chapter 17 - Entities Tags
HTML entities are a crucial part of HTML markup language. They enable you to
display characters that are reserved in HTML or that aren't readily available on the
keyboard. In this blog, we'll explore what HTML entities are, their types, and how
to use them.
Reserved Characters: Characters like <, >, and & are reserved in HTML.
Non-Breaking Spaces: To create white spaces that won't break into a new
line.
Lessons 31
Creating Non-Breaking Spaces
<p>This is an example text.</p>
Lessons 32