Professional Documents
Culture Documents
HTML Tutorial HTML Exercises HTML Tags HTML Attributes Global Attributes Event Attributes HTML Inter
HTML Basics
HTML Basics contains all the basic HTML examples. HTML is the basic
language for web content creation. It is used to create a structure or blueprint
of the web documents.
Basics of HTML include learning HTML tags ( <h1>, <p>, <img>, etc),
attributes, elements, and document structure which collectively form a
working web page.
In this guide, we will be covering basic HTML concepts with examples and
learn how to create a web page.
Table of Content
https://www.geeksforgeeks.org/html-basics/?ref=lbp 1/14
4/1/24, 5:03 AM HTML Basics - GeeksforGeeks
Please refer to the HTML Doctypes article for more information related
to Doctypes.
Below mentioned are the basic HTML tags that divide the whole page into
various parts like head, body, etc.
Tags Descriptions
Encloses the entire HTML document, serving as the root element for all
<html>
HTML content.
Used within the <head> section to define the title of the HTML
<title> document. It appears in the browser tab or window and provides a brief
description of the webpage’s content.
Example
HTML
https://www.geeksforgeeks.org/html-basics/?ref=lbp 2/14
4/1/24, 5:03 AM HTML Basics - GeeksforGeeks
<!DOCTYPE html>
<html>
<head>
<!-- Information about the web page -->
<!--This is the comment tag-->
<title>GeeksforGeeks</title>
</head>
<body>
<!--Contents of the webpage-->
<p>GeeksforGeeks is a online study platform</p>
</body>
</html>
Output:
HTML Headings
HTML Heading tag helps us to give headings to the content of a webpage.
These tags are mainly written inside the body tag. HTML provides six heading
tags from <h1> to <h6>. Every tag displays the heading in a different font size.
Syntax
<h1></h1>
<h2></h2>
<h3></h3>
<h4></h4>
<h5></h5>
https://www.geeksforgeeks.org/html-basics/?ref=lbp 3/14
4/1/24, 5:03 AM HTML Basics - GeeksforGeeks
<h6></h6>
Example
This example illustrates the use of 6 heading tags from <h1> to <h6> in
HTML.
HTML
<!DOCTYPE html>
<html>
<head>
<title>HTML heading tag</title>
</head>
<body>
<h1>Heading 1 (h1)</h1>
<h2>Heading 2 (h2)</h2>
<h3>Heading 3 (h3)</h3>
<h4>Heading 4 (h4)</h4>
<h5>Heading 5 (h5)</h5>
<h6>Heading 6 (h6)</h6>
</body>
</html>
Output:
https://www.geeksforgeeks.org/html-basics/?ref=lbp 4/14
4/1/24, 5:03 AM HTML Basics - GeeksforGeeks
HTML <br> tag is used to insert a single line break. It does not have any
closing tag. In HTML, the break tag is written as <br>.
Syntax
// for Parapgraph
<p> Content... </p>
// for Break
<br>
Example
This example illustrates the use of <p> tag for writing a paragraph statement
in HTML.
HTML
<!DOCTYPE html>
<html>
<head>
<title>
Example of paragraph and break elements
</title>
</head>
<body>
https://www.geeksforgeeks.org/html-basics/?ref=lbp 5/14
4/1/24, 5:03 AM HTML Basics - GeeksforGeeks
<p>
HTML stands for HyperText Markup Language.<br>
It is used to design web pages using a markup
language.<br>HTML is a combination of Hypertext
and Markup language.<br>Hypertext defines the
link between web pages.<br>A markup language
is used to define the text document within the
tag which defines the structure of web pages.
</p>
</body>
</html>
Output:
Syntax
<hr>
Example
This example illustrates the use of the <hr> tag for the horizontal line in
HTML.
https://www.geeksforgeeks.org/html-basics/?ref=lbp 6/14
4/1/24, 5:03 AM HTML Basics - GeeksforGeeks
HTML
<!DOCTYPE html>
<html>
<head>
<title>HTML <hr> tag</title>
</head>
<body>
<h1>Hello GeeksforGeeks</h1>
<p>
A Computer Science portal for geeks<br>
A Computer Science portal for geeks<br>
A Computer Science portal for geeks<br>
</p>
<hr>
<p>
A Computer Science portal for geeks<br>
A Computer Science portal for geeks<br>
A Computer Science portal for geeks<br>
</p>
<hr>
<p>
A Computer Science portal for geeks<br>
A Computer Science portal for geeks<br>
A Computer Science portal for geeks<br>
</p>
<hr>
</body>
</html>
Output:
HTML Images
The <image> tag is used to insert an image into our web page. The source of
the image to be inserted is put inside the <img src=”source_of_image“> tag.
Syntax
<img src="geeks.png">
Example
https://www.geeksforgeeks.org/html-basics/?ref=lbp 7/14
4/1/24, 5:03 AM HTML Basics - GeeksforGeeks
This example illustrates the use of the <img> tag for inserting the images in
HTML.
HTML
<!DOCTYPE html>
<html>
<head>
<title>HTML img tag</title>
</head>
<body>
<img src=
"https://media.geeksforgeeks.org/wp-content/cdn-uploads/Geek_logi_-low_res.png">
</body>
</html>
Output:
To view the source code of a webpage press ctrl + u on the page, or right-click
on the page and select the “view page source” option.
This will open a new tab that shows the HTML source code for that entire
page.
To check the HTML code for a specific element on a page, right-click on the
page and select the “Inspect” option.
https://www.geeksforgeeks.org/html-basics/?ref=lbp 8/14
4/1/24, 5:03 AM HTML Basics - GeeksforGeeks
This lets you see the HTML and CSS behind that element. You can also try
making changes and see the changes.
Conclusion
HTML is the fundamental of web development. As a beginner people get
overwhelmed with information available online. This guide aims to provide
slow and easy exposure to HTML. We have explained HTML basics with
examples to provide a better understanding of HTML.
The basics of HTML are taught in the correct flow, which helps you understand
the basic HTML structure and enables you to create your first HTML web page.
https://www.geeksforgeeks.org/html-basics/?ref=lbp 9/14
4/1/24, 5:03 AM HTML Basics - GeeksforGeeks
“This course was packed with amazing and well-organized content! The
project-based approach of this course made it even better to understand
concepts faster. Also the instructor in the live classes is really good and
knowledgeable.”- Tejas | Deutsche Bank
With our revamped Full Stack Development Program: master Node.js and
React that enables you to create dynamic web applications.
So get ready for salary hike only with our Full Stack Development Course.
Previous Next
Similar Reads
https://www.geeksforgeeks.org/html-basics/?ref=lbp 10/14
4/1/24, 5:03 AM HTML Basics - GeeksforGeeks
GeeksforGeeks
https://www.geeksforgeeks.org/html-basics/?ref=lbp 11/14
4/1/24, 5:03 AM HTML Basics - GeeksforGeeks
Company Explore
About Us Hack-A-Thons
Legal GfG Weekly Contest
Careers DSA in JAVA/C++
In Media Master System Design
Contact Us Master CP
Advertise with us GeeksforGeeks Videos
GFG Corporate Solution Geeks Community
Placement Training Program
Languages DSA
Python Data Structures
Java Algorithms
C++ DSA for Beginners
PHP Basic DSA Problems
GoLang DSA Roadmap
SQL Top 100 DSA Interview Problems
R Language DSA Roadmap by Sandeep Jain
Android Tutorial All Cheat Sheets
Tutorials Archive
https://www.geeksforgeeks.org/html-basics/?ref=lbp 12/14
4/1/24, 5:03 AM HTML Basics - GeeksforGeeks
https://www.geeksforgeeks.org/html-basics/?ref=lbp 13/14
4/1/24, 5:03 AM HTML Basics - GeeksforGeeks
https://www.geeksforgeeks.org/html-basics/?ref=lbp 14/14