HTML Introduction
HTML Introduction
What is HTML?
HTML is an initialism for "HyperText Markup Language" .
It is the language of the web.
It is used to create websites.
It is used to define a page layout, meaning it is a barebone page structure.
HTML is used for making pages of the website also called webpages that we see on
the internet
It consists of a set of tags.
This set of tags is written in HTML Document.
".html" or ".htm" is the extension.
There are so many versions of HTML but HTML5 is the latest version.
Features of HTML
It is platform-independent.
Images, videos, and audio can be added to a web page.
Hypertext can be added to the text.
It is a markup language.
It is interpreted language
It can be integrated with other languages like CSS, JavaScript etc.
Semantic Structure.
local Storage & Indexed DB – Client-side data storage.
Offline Capabilities (PWA) with Cache API & Service Workers.
HTML Working
When we want to access any information on the internet we search that on a web
browser. The web browser gets all the content from the web servers. This content is
stored in the webservers in the form of an HTML document.
An HTML document is first written with some tags in any code editor or your choice of
a text editor and then saved with the “ .html ” extension. After this, the browser
interprets the HTML document, reads it, and renders a web page.
In the above figure, we open a simple text editor, then the basic structure is to be
written. Now, this file is to be saved with the "index.html" filename. After saving this
file, open this file in your web browser. After opening our webpage will look like as the
output.
Below we'll discuss this line briefly.
How does HTML Works?
HTML Document:
It's a text document saved with the extension .html or .htm that contains texts and
some tags written between "< >" which give the instructions needed to configure the
web page.
These tags are fixed and definite. About the structure of html document is explained
further.
Browser:
A browser is an application that reads HTML documents and renders the webpage.
They cannot read the content directly where it is stored. To settle this conflict
servers are used.
A server acts like an intermediate, it patiently listens to the browser's request and
executes it.
Now the document is delivered to the browser.
Browsers support two parts now: parsing and rendering.
When the browser is in the parsing stage, it receives raw bytes which are converted
into characters and these characters are then converted into tokens after that tokens
are converted into nodes. Then these nodes are linked in a tree data structure
known as DOM(Document Object Model).
when the DOM tree structure has been constructed, the browser starts its rendering.
Now each node in the DOM tree will be rendered and displayed.
Rendered Page:
The rendered page is the output screen of our HTML Document which is the page
displayed on the browser
How does the basic website work?
HTML Prerequisite
Tools needed to make an HTML page:
1) HTML Editors: It is a simple tool in which every piece of HTML content has to be
written. We can use any text editor as per our choice. Here we are using Visual studio
code because it is lightweight and open-source.
Commonly used editors:
NOTE: You can write HTML even in a Notepad. Text editors like VS code make
these things easier.
Installation of Visual Studio Code:
Go to Google
Type Visual studio code download
Click on download and install it as per your OS
2) Browser: HTML tags are not displayed by browsers, but are read and interpreted
by them. In a web browser, HTML structures are rendered into a styled and pretty
form. Here we are using google chrome.
Commonly used browsers:
Using any editor and any browser, we will be able to render pages.
NOTE: In addition, we are installing a live server extension in our Vscode editor to
view live reload pages.
live server extension is used to launch a local development server with a live reload
feature for HTML pages.
HTML Document Structure
How does an HTML document structure look?
HTML document structure contains some set of tags. Tags are some text enclosed within <…
> angle braces. A tag is like a container for either content or other HTML tags. The below text
shows how the HTML document structure looks:
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
</head>
<body>
<!-- content -->
</body>
</html>
Copy
1. <!DOCTYPE html>
Copy
The <!DOCTYPE> declaration tag is used by the web browser to understand the version of the
HTML used in the document. The current version is 5 i.e. HTML 5.
2. <html>
Copy
3. <head>
Copy
4. <title>Document</title>
Copy
The <title> tag contains the title of a page and is shown in the browser title bar.
5. </head>
Copy
The </head> tag is closing of <head> tag.
6. <body>
Copy
<body> tag is the main tag of HTML. It contains the main body of the page and is shown in the
white part of the browser.
7. </body>
Copy
8. </html>
Copy
Copy
Visualization of this HTML document:
Display of this content on a web browser:
In the browser's title bar, all content of the <head> section will be displayed, while on the white
background of the browser, all content of the <body> section will be displayed.
HTML Editors
HTML using Notepad:
Step1: Go to notepad
Step2: Write HTML code in it
Step3: Save with ".html" extension
Step4: Open this file in the browser
Go to that website.
Click the right mouse button.
Select the option View Page Source.
A new tab with view-source will appear on your screen.
How to inspect the HTML element?
Sometimes we want to inspect the HTML element of someone’s website and to do that
there is a simple technique which is provided by windows.
Go to that website.
Click the right mouse button.
Select the option Inspect.
Now developer tool is opened on your screen.
NOTE: You are permitted to temporarily edit/change CSS or HTML elements on
any website utilizing this developer tool.
HTML Tags
What is an HTML tag?
If you want to build a beautiful website. Tags will help you to do so.
A tag is like a container for either content or other HTML tags. Tags are words
enclosed within < and > braces.
They are like keywords which defines that how web browser will format and display the
content
Some of the tags are mentioned below,
<html>
Copy
<head>
Copy
<title>
Copy
<body>
Copy
Closing tags are used to close the content in between them. These are the tags
enclosed within angle braces <,> and a forward slash /. For example: </html>. These
closing tags are also known as “Ending tags”.
Some tags don’t have their corresponding closing tags and these are known
as “Stand-Alone tags” / “Empty tags” / “Self-closing tags”. For example:
NOTE: In these Empty tags, they have a space between the characters and the
forward-slash (/). This is because if you omit this space, older browsers will
have trouble rendering that line break.
pictorial representation of tags:-
HTML Elements
What is an HTML Element?
HTML Element is a combination of the start tag, content, and end tag.
HTML Element = Start tag + Content + End tag
For example:
Copy
Copy
<br/>
Copy
Skeletal Tags
Some basic tags and their meanings are discussed below:
<html>
//content
</html>
Copy
As discussed above, all the contents are wrapped in between the opening
tag <html> and the closing tag </html>. In between <html> and </html> tag, our
content contains two parts i.e. a header section i.e. <head>...</head> and a body
section i.e. <body>...</body> .
<head>
//head content
</head>
Copy
Our header section starts from <head> and closes at </head> tag. It defines the head
of a document. This tag contains meta tags i.e. <meta>....</meta> and a title tag
i.e. <title >...</title> . The title is shown in the top tab of your browser but
metadata is not displayed anywhere, it is generally used for SEOs and contains
information about the document.
<title>
//any title name
</title>
Copy
Our title section starts from <title> and closes at </title> tag. It defines the title of a document.
<body>
//body content
</body>
Copy
Our body section starts from <body> and closes at </body> tag. It defines the body of a document. This tag
contains various other tags. All the contents in between this tag are displayed on a web browser
The below image shows the skeletal tags and must needed tags to define the layout of the
webpage
Heading Tags
For any headlines use these heading tags on your HTML page.
<h1> tag: “define heading of an HTML page but with first level”
Syntax:
<h1>
//heading content
</h1>
Copy
The <h1> tag is the first level heading tag. It also has its corresponding
close </h1> tag. <h1> tag shows the biggest and the boldest heading from all the six-
level heading tags. Font-size are predefined in this tag.
<h2> tag: “define heading of an HTML page but with second level”
Syntax:
<h2>
//heading content
</h2>
Copy
The <h2> tag is the second-level heading tag. It also has its corresponding
close </h2> tag. <h2> tag comes after the <h1> tag i.e. Font-size is a little bit smaller
than <h1> tag.
<h3> tag: “define heading of an HTML page but with third level”
Syntax:
<h3>
//heading content
</h3>
Copy
<h4> tag: “define heading of an HTML page but with fourth level”
Syntax:
<h4>
//heading content
</h4>
Copy
<h5> tag: “define heading of an HTML page but with fifth level”
Syntax:
<h5>
//heading content
</h5>
Copy
<h6> tag: “define heading of an HTML page but with sixth level”
Syntax:
<h6>
//heading content
</h6>
Copy
Paragraph Tag
For paragraphs use <p> tag on your HTML page.
<p> tag: “defines a paragraph on an HTML page”
Syntax:
<p>
//paragraph content
</p>
Copy
Syntax:
<hr />
Copy
The <hr / > tag is also known as the empty tag where a closing tag is not needed.
This tag is a self-closing tag. A horizontal line tag is used to break your documents
visually by adding a horizontal line in your document.
Line Break Tag
For line break use <br /> tag on your HTML page.
<br /> tag: “used to break two lines or paragraph on an HTML page”
Syntax:
<br />
Copy
The <br / > tag is also known as the empty tag where a closing tag is not needed.
This tag is a self-closing tag. A line break tag is used to break down your line or a
paragraph. When the <br /> tag is used it automatically breaks the paragraph into a
new line.
Center Tag
To put content in the center use <center> tag on your HTML page.
<center> tag: “used to put content in the center on an HTML page”
Syntax:
<center>
//content
</center>
Copy
The <center> tag is used to put your content in the center of your HTML page. You
can use this tag in your table also. Sometimes we need our text to be in the center for
that this <center> tag is used. This tag has both an opening and a closing tag. It is not
an empty tag.
Refer to the video to understand clearly:
NOTE: According to HTML5, this tag has been deprecated and is now obsolete.
We'll learn more about deprecated tags in the upcoming tutorial.
<pre> tag: “used to put the exact code on an HTML page”
Syntax:
<pre>
//code of any programming language
</pre>
Copy
Preserve formatting itself defines preserving the format of the source document.
The <pre> tag is used to put your content the same as it is on your HTML page. This
tag has both an opening and a closing tag. Sometimes we need our text to be written
on our HTML page the same as it is for that we use the <pre> tag.
Monospaced Font
For monospaced font use <tt> tag on your HTML page.
<tt> tag: “used to display each letter with same width on an HTML page”
Syntax:
<tt>
//content
</tt>
Copy
Using this <tt> tag we can display each letter with the same width. <tt> tag has also
its corresponding </tt> tag. Each letter of an alphabet has different widths like ‘w’ is
wider than ‘i’ so to overcome this we can use a monospaced font. The monospaced
font displays each letter with the same width.
<abbr>
//content
</abbr>
Copy
Acronym Tag
For acronym text use <acronym> tag on your HTML page.
<acronym> tag: “used to define acronym”
Syntax:
<acronym>
//content
</acronym>
Copy
Using this <acronym> tag we can define an acronym text. <acronym> tag has also its
corresponding </acronym> tag.
Blockquote Tag
To insert long quote use <blockquote> tag on your HTML page.
<blockquote> tag: “used to insert long quote on an HTML page”
Syntax:
<blockquote>
//content
</blockquote>
Copy
Using this <blockquote> tag we can insert a long quotation on an HTML
page. <blockquote> tag has also its corresponding </blockquote> tag.
Quote Tag
To insert short quote use <q> tag on your HTML page.
<q> tag: “used to insert a short quote or to add a double quote on an HTML
page”
Syntax:
<q>
//content
</q>
Copy
Using this <q> tag we can insert a double quote on an HTML page. <q> tag also has its
corresponding </q> tag.
<cite> tag: “used to provide a reference or defines the title of a creative work
on an HTML page”
Syntax:
<cite>
//content
</cite>
Copy
Using this <cite> tag we can provide a reference or title for creative work on the
HTML page. <cite> tag also has its corresponding </cite> tag. By default content
between this tag is shown in italic.
<bdo> tag: “used to override the current direction of text on an HTML page”
Syntax:
<bdo>
//content
</bdo>
Copy
<address> tag: “used to show contact information on an HTML page”
Syntax:
<address>
//content
</address>
Copy
Code Tag
To show programming code, use the <code> tag on your HTML page.
<code> tag: “used to show programming code on an HTML page”
Syntax:
<code>
//content
</code>
Copy