HTML Basics contains all the basic examples of HTML coding. HTML is the basic language for web content creation. It is used to create a structure or blueprint of the web documents.
There are various tags like <h1>, <p>, and <img> define various content elements. HTML provides hyperlinking using an anchor tag (<a> tag) that allows navigation.
Basic HTML Document
Below mentioned are the basic HTML tags that divide the whole document into various parts like head, body, etc. Every HTML document begins with an HTML document tag. Although this is not mandatory, it is a good convention to start the document with the below-mentioned tag. Please refer to the HTML Doctypes article for more information related to Doctypes.
|
| <html> | Encloses the entire HTML document, serving as the root element for all HTML content. |
| <head> | Contains header information about the webpage, including title, meta tags, and linked stylesheets. It is part of the document’s structure but is not displayed on the webpage. |
| <title> | Used within the <head> section to define the title of the HTML document. It appears in the browser tab or window and provides a brief description of the webpage’s content. |
<body> | Encloses the visible content of the webpage, such as text, images, audio, videos, and links. All elements within this tag are displayed on the actual webpage when viewed in a browser. |
Example: This example illustrates the HTML basic structure.
HTML
<!DOCTYPE html>
<html>
<head>
<title>GeeksforGeeks</title>
</head>
<body>
<p>GeeksforGeeks is a online study platform</p>
</body>
</html>
|
It just shows the basic pattern of how to write the HTML code and will name the title of the page as GeeksforGeeks. <! – – comment here – – > is the comment tag in HTML and it doesn’t read the line present inside this tag.
Output:

HTML Headings
The 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>
<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:

HTML Paragraph and Break Elements
The <p> tags help us to write paragraph statements on a webpage. They start with the <p> tag and ends with </p>. The <br> tags 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>
<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:

HTML Horizontal Line
The <hr> tag is used to break the page into various parts, creating horizontal margins with help of a horizontal line running from the left to right-hand side of the page. This is also an empty tag and doesn’t take any additional statements.
Syntax:
<hr>
Example: This example illustrates the use of the <hr> tag for the horizontal line in HTML.
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:

Adding horizontal line using the <hr> tag
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: 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=
</body>
</html>
|
Output:

Adding image using tag
HTML is the foundation of web pages and is used for webpage development by structuring websites and web apps. You can learn HTML from the ground up by following this HTML Tutorial and HTML Examples.
Last Updated :
22 Jan, 2024
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...