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.
.png)
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 |
| <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:
<!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.