0% found this document useful (0 votes)
68 views14 pages

HTML Basics - GeeksforGeeks

HTML (HyperText Markup Language) is the standard markup language for creating and structuring web pages, using elements and tags for layout. This guide covers the basics of HTML, including document structure, common tags, and best practices for web development. Understanding HTML is essential for creating functional and engaging websites.

Uploaded by

abuyumnah23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views14 pages

HTML Basics - GeeksforGeeks

HTML (HyperText Markup Language) is the standard markup language for creating and structuring web pages, using elements and tags for layout. This guide covers the basics of HTML, including document structure, common tags, and best practices for web development. Understanding HTML is essential for creating functional and engaging websites.

Uploaded by

abuyumnah23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

HTML Basics

Last Updated : 17 Jul, 2025

HTML (HyperText Markup Language) is the standard markup language


used to create and structure web pages.

It defines the layout of a webpage using elements and tags, allowing


for the display of text, images, links, and multimedia content.
As the foundation of nearly all websites, HTML is used in over 95% of
all web pages today, making it an essential part of modern web
development.

In this guide, we learn the basics of HTML, which includes HTML tags (
<h1>, <p>, <img>, etc), attributes, elements, and document structure which
collectively form a working web page.

HTML Basic Document and Structure


Every HTML document begins with a document type declaration, setting
the foundation for the webpage. This section introduces basic HTML tags
that structure the page, such as <head>, <body>, and <title>. Although this
is not mandatory, it is a good convention to start the document with the
below-mentioned tag.


Personalized Mediterranean
Diet Plan To Lose Weight
No.Diet

HTML Structure

Below mentioned are the basic HTML tags that divide the whole page into
various parts like head, body, etc.
Basic HTML Tags for Document Structure

Tags Descriptions

Encloses the entire HTML document, serving as the root element


<html>
for all HTML content.

Contains header information about the webpage, including title,


<head> meta tags, and linked stylesheets. It is part of the document's
structure but is not displayed on the webpage.

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.

Encloses the visible content of the webpage, such as text, images,


<body> audio, videos, and links. All elements within this tag are displayed
on the actual webpage when viewed in a browser.

Example:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>HTML</title>
</head>
<body>
<!--Contents of the webpage-->
<p>GeeksforGeeks is a online study platform</p>
</body>
</html>

Code Overview:

This HTML document defines a basic webpage with a responsive


design using <meta> tags, ensuring it adjusts well to different devices.
The content includes a paragraph <p> displaying "GeeksforGeeks is an
online study platform," and the title "HTML" appears in the browser tab.

HTML Headings
The HTML heading tags are used to create headings for the content of a
webpage. These tags are typically placed inside the body tag. HTML
offers six heading tags, from <h1> to <h6>, each displaying the heading in
a different font size.

Syntax:

<h1></h1>
<h2></h2>
<h3></h3>
<h4></h4>
<h5></h5>
<h6></h6>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>HTML</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>

Code Overview:

This code displays six headings (<h1> to <h6>) on the webpage, with
<h1> being the largest and most prominent and <h6> being the
smallest.
The headings are used to define text hierarchy and emphasize content
based on importance.

HTML Paragraph and Break Elements


HTML <p> tags are used to write paragraph statements on a webpage.
They start with the <p> tag and end with </p>. The HTML <br> tag is used
to insert a single line break and does not require a closing tag. In HTML,
the break tag is written as <br>.

Syntax:
// for Paragraph
<p> Content... </p>
// for Break
<br>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>HTML</title>
</head>
<body>
<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>

Code Overview:
This HTML code uses a <p> tag to display a paragraph of text,
providing an overview of what HTML is and its purpose.
The <br> tags are used to insert line breaks, making the text more
readable by separating each sentence onto a new line within the
paragraph.

HTML Horizontal Line


The HTML <hr> tag is used to divide a page into sections by creating a
horizontal line that spans from the left to the right side of the page. This is
an empty tag and does not require a closing tag or any additional
attributes.

Syntax:

<hr>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>HTML</title>
</head>
<body>
<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>

Code Overview:

<h1> to <h6> tags are used to define headings, with <h1> being the
largest and <h6> the smallest.
Each tag displays "Hello World!" in decreasing font sizes, illustrating
the hierarchy of headings in HTML.

HTML Comments
HTML comments are annotations in your code that are not displayed in
the browser. They are enclosed within <!-- and --> tags and are primarily
used for documentation, explanation, or temporarily disabling code during
debugging.

Syntax of HTML Comments

Single-line comment:

<!-- This is a single-line comment -->

Multi-line comment:

<!--
This is a multi-line comment
spanning multiple lines
-->

Example Usage of HTML Comments

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>HTML</title>
</head>
<body>
<!-- This is a heading tag -->
<h1>Welcome to GeeksforGeeks</h1>
<!-- This is a paragraph tag -->
<p>Learn HTML, CSS, and JavaScript here.</p>
</body>
</html>

In this example, the comments provide context about the purpose of each
HTML element.

Best Practices for Using HTML Comments


Be concise and relevant: Write comments that explain the "why" behind
the code in a brief and clear manner.
Avoid over-commenting: Do not state the obvious. Let the code itself
explain when possible.
Keep comments up-to-date: Ensure comments reflect changes in the
code to avoid confusion.

HTML Images
The <img> tag is used to insert an image into a webpage. The source of
the image is specified within the src attribute, like this: <img
src="source_of_image">.

Syntax:

<img src="geeks.png">

This HTML code uses the <img> tag to display an image on a


webpage.
The src attribute specifies the URL of the image, which is loaded and
displayed when the page is rendered in the browser.

View HTML Source Code


While checking a web page, you might want to see the HTML code behind
it. Here we will see how you can view HTML source code for the entire
page or a specific element.

1. View HTML Source Code of Entire Page

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.

2. Inspect an HTML Element on a Page

To check the HTML code for a specific element on a page, right-click


on the page and select the "Inspect" option.
This lets you see the HTML and CSS behind that element. You can also
try making changes and see the changes.

Conclusion
Understanding HTML is the first step in becoming a web developer. By
learning the basic tags and structure, you can create well-organized and
functional web pages. The more you practice and experiment with HTML,
the better you'll understand how to create interactive, engaging, and well-
optimized websites.

Advertise with us Next Article


HTML Elements

C Chinmoy Lenka GfG Test

370

Similar Reads

HTML Tutorial
HTML stands for HyperText Markup Language. It is the standard language used to create and structure
content on the web. It tells the web browser how to display text, links, images, and other forms of…

11 min read

Basics

HTML Introduction
HTML stands for Hyper Text Markup Language, which is the core language used to structure content
on the web. It organizes text, images, links, and media using tags and elements that browsers can…

6 min read

HTML Editors
An HTML Editor is a software application designed to help users create and modify HTML code. It
often includes features like syntax highlighting, tag completion, and error detection, which facilitate…

5 min read

HTML Basics
HTML (HyperText Markup Language) is the standard markup language used to create and structure
web pages. It defines the layout of a webpage using elements and tags, allowing for the display of…

7 min read
HTML Structure & Elements

HTML List

HTML Visuals & Media

HTML Layout & Design

HTML Projects& Advanced Topics

HTML Tutorial References

Article Tags : HTML Web technologies-HTML and XML HTML5 HTML-Basics

Corporate & Communications


Address:
A-143, 7th Floor, Sovereign Corporate
Tower, Sector- 136, Noida, Uttar
Pradesh (201305)

Registered Address:
K 061, Tower K, Gulshan Vivante
Apartment, Sector 137, Noida,
Gautam Buddh Nagar, Uttar Pradesh,
201305

Advertise with us

Company Languages
About Us Python
Legal Java
Privacy Policy C++
In Media PHP
Contact Us GoLang
Advertise with us SQL
GFG Corporate Solution R Language
Placement Training Program Android Tutorial
Tutorials Archive

DSA Data Science & ML


Data Structures Data Science With Python
Algorithms Data Science For Beginner
DSA for Beginners Machine Learning
Basic DSA Problems ML Maths
DSA Roadmap Data Visualisation
Top 100 DSA Interview Problems Pandas
DSA Roadmap by Sandeep Jain NumPy
All Cheat Sheets NLP
Deep Learning

Web Technologies Python Tutorial


HTML Python Programming Examples
CSS Python Projects
JavaScript Python Tkinter
TypeScript Python Web Scraping
ReactJS OpenCV Tutorial
NextJS Python Interview Question
Bootstrap Django
Web Design

Computer Science DevOps


Operating Systems Git
Computer Network Linux
Database Management System AWS
Software Engineering Docker
Digital Logic Design Kubernetes
Engineering Maths Azure
Software Development GCP
Software Testing DevOps Roadmap

System Design Inteview Preparation


High Level Design Competitive Programming
Low Level Design Top DS or Algo for CP
UML Diagrams Company-Wise Recruitment Process
Interview Guide Company-Wise Preparation
Design Patterns Aptitude Preparation
OOAD Puzzles
System Design Bootcamp
Interview Questions

School Subjects GeeksforGeeks Videos


Mathematics DSA
Physics Python
Chemistry Java
Biology C++
Social Science Web Development
English Grammar Data Science
Commerce CS Subjects
World GK

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

You might also like