The Wayback Machine - https://web.archive.org/web/20241011113301/https://www.geeksforgeeks.org/html-basics/
Open In App

HTML Basics

Last Updated : 06 Aug, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

HTML stands for Hyper Text Markup Language. It is the standard markup language for creating Websites. It is used to describe the structure of a Web page. HTML consists of elements that tell the browser how the content is displayed on the screen. We’ll walk you through fundamental HTML examples and teach you how to create a webpage. This HTML Basics covers fundamental HTML examples.

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

Basic HTML Document

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. 

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

TagsDescriptions
<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 1: To illustrates the Basic HTML structure.

HTML
<!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>

Output:

HTML-Basic-Example

HTML Basic Example Output

HTML Basic Structure

Screenshot-(4)

HTML Structure

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>

Example 2: To demonstrate the use of 6 heading tags from <h1> to <h6> in HTML.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0">
      <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 heading tags output

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 Parapgraph

<p> Content... </p>

// for Break
<br>

Example 3: To illustrates the use of <p> tag for writing a paragraph statement in HTML.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0">
      <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 paragraph tag and break tag

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>

Example 4: To illustrates the use of the <hr> tag for the horizontal line in HTML.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0">
    <title>HTML &lt;hr&gt; 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 horizontal line using <hr> tag output

HTML Horizontal Line

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">

Example 5: To illustrates the use of the <img> tag for inserting the images in HTML.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0">
      <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:

html <img> tag output

Adding image using img tag

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.

FAQs – HTML Basics

What are the basics of HTML?

Basic HTML includes mastering document structure, tags, and their attributes and elements.

What are the basic rules of HTML?

Some basic rules of HTML are:

  • The basic HTML structure is fixed with doctype declaration, html, head, title, and body tags. The content then can be added to the body tag.
  • Tags are enclosed in < and >. A tag should have an opening tag(eg <h1>) and a closing tag(eg </h1>).
  • HTML Tags are not case-sensitive.

What are the uses of HTML?

HTML is used to build page structure, create hyperlinks(using <a> tag), embed multimedia on page(with <img>, <video>, or <audio> tag) and HTML is the foundation of web development.



Previous Article
Next Article

Similar Reads

HTML Course Basics of HTML
In this article, we will go through all the basic stuff required to write HTML. There are various tags that we must consider and know about while starting to code in HTML. These tags help in the organization and basic formatting of elements in our script or web pages. These step-by-step procedures will guide you through the process of writing HTML.
5 min read
HTML Canvas Basics
In this article, we will know HTML Canvas Basics, and their implementation through the examples. The HTML "canvas" element is used to draw graphics via JavaScript. The "canvas" element is only a container for graphics. One must use JavaScript to actually draw the graphics. Canvas has several methods for drawing paths, boxes, circles, text, and addi
4 min read
Learn Web Development Basics with HTML CSS and JavaScript
Web development refers to the creating, building, and maintaining of websites. It includes aspects such as web design, web publishing, web programming, and database management. It is the creation of an application that works over the internet i.e. websites. The word Web Development is made up of two words, that is: Web: It refers to websites, web p
4 min read
HTML SVG Basics
SVG stands for Scalable Vector Graphics. It defines vector-based graphics in XML format. SVG graphics do not lose any quality when zoomed or resized, and every element and attribute in SVG files can be animated. Advantages of SVG: The advantages of using SVG over other image formats (like JPEG and GIF) are: SVG images scale without losing quality,
4 min read
Foundation CSS Media Object Basics
Foundation CSS is an open-source and responsive front-end framework created by ZURB in September 2011 that makes it simple to create stunning responsive websites, apps, and emails that operate on any device. Many companies, like Facebook, eBay, Mozilla, Adobe, and even Disney, use it. This framework is based on bootstrap, which is similar to SaaS.
3 min read
Basics of phpMyAdmin
As we know that, any simple website or application needs interaction with data or data management, so it uses databases phpMyAdmin has become one of the popular, free, open-source software platform for administration of MySQL and MariaDB data over the web world. This tool is primarily written in PHP for web hosting and related services. This GUI to
8 min read
Laravel | Routing Basics
Once you have installed Laravel and your basic Web App is up and running. Let's just look more deeply into the framework and see how we can work with routes. Routes: Routes are actually the web URLs that you can visit in your web application. For example /home, /profile, /dashboard etc are all different routes that one can create in a Laravel Appli
4 min read
Basics of the Blockchain and its various applications
The BlockChain, to begin with is undeniably one of the most ingenious inventions of mankind. Considering it to be the brainchild the pseudonym, Satoshi Nakamoto, the technology has evolved into something unimaginably great. However, the most commonly asked always arises every single time - What is this Blockchain? A BlockChain is defined as a peer
5 min read
Laravel | Controller Basics
Laravel is an MVC based PHP framework. In MVC architecture, 'C' stands for 'Controller'. A Controller is that which controls the behavior of a request. It handles the requests coming from the Routes. In Laravel, a controller is in the ‘app/Http/Controllers’ directory. All the controllers, that are to be created, should be in this directory. We can
2 min read
Laravel | View Basics
Laravel is an MVC based PHP framework. In MVC architecture, V stands for View. The View is data that is going to be displayed to the user on their browser and the user can interact with it. It is simply an interface provided to the user for interaction. Laravel used a powerful templating engine called Blade. The extension for this file used here is
8 min read
Laravel | Migration Basics
In Laravel, Migration provides a way for easily sharing the schema of the database. It also makes the modification of the schema much easier. It is like creating a schema once and then sharing it many times. It gets very useful when you have multiple tables and columns as it would reduce the work over creating the tables manually. To Create Migrati
4 min read
Laravel | Eloquent Model Basics
Laravel is an MVC based PHP framework. In MVC architecture, ‘M’ stands for ‘Model’. A Model is basically a way for querying data to and from the table in the database. Laravel provides a simple way to do that using Eloquent ORM (Object-Relational Mapping). Every table has a Model to interact with the table. Create a Model: To create an Eloquent Mod
5 min read
PugJS Basics and Installation
Pug.js is a template engine for Node.js and browsers to render dynamic reusable content. At compile time, the template engine compiles our Pug template code to HTML. We can use variables in pug just like in JavaScript. At runtime, the template engine injects or replaces variables in a template file with actual values, and transforms the template in
3 min read
Sails.js Basics and Installation
Node.js: Node.js is an open-source and cross-platform runtime environment for executing JavaScript code outside a browser. You need to remember that NodeJS is not a framework and it’s not a programming language. Most of the people are confused and understand it’s a framework or a programming language. We often use Node.js for building back-end serv
2 min read
Blaze UI Basics Card
Blaze UI is a CSS open-source framework. It is a lightweight UI toolkit and provides great tools for building customized and scalable applications. It can work with any framework that exists. It can adapt to any ecosystem. All designs or CSS are mobile-first and hence responsive. It project is available open-source so a large community maintains it
2 min read
Bulma Column Basics
Bulma is a free and open-source CSS framework based on Flexbox. It is component-rich, compatible, and well documented. It is highly responsive in nature. It uses classes to implement its design. Bulma columns can create columns for our web page. Columns are an essential part of any web page and generally, it can be difficult to create them as requi
3 min read
Foundation CSS Button Group Basics
Foundation CSS is an open-source & responsive front-end framework built by ZURB foundation in September 2011, that makes it easy to design beautiful responsive websites, apps, and emails that look amazing & can be accessible to any device. It is used by many companies such as Facebook, eBay, Mozilla, Adobe, and even Disney. The framework is
2 min read
Foundation CSS Pagination Basics
Foundation CSS is an open-source & responsive front-end framework built by ZURB foundation in September 2011, that makes it easy to design beautiful responsive websites, apps, and emails that look amazing & can be accessible to any device. It is used by many companies such as Facebook, eBay, Mozilla, Adobe, and even Disney. The framework is
2 min read
Foundation CSS Accordion Basics
Foundation CSS is an open-source and responsive front-end framework created by ZURB in September 2011 that makes it simple to create stunning responsive websites, apps, and emails that operate on any device. Many companies, like Facebook, eBay, Mozilla, Adobe, and even Disney, use it. This framework is based on bootstrap, which is similar to SaaS.
3 min read
Foundation CSS Top Bar Basics
Foundation CSS is an open-source & responsive front-end framework built by ZURB foundation in September 2011, that makes it easy to design beautiful responsive websites, apps, and emails that look amazing & can be accessible to any device. It is used by many companies such as Facebook, eBay, Mozilla, Adobe, and even Disney. The framework is
3 min read
Foundation CSS Accordion Menu Basics
Foundation CSS is an open-source and responsive front-end framework created by ZURB in September 2011 that makes it simple to create stunning responsive websites, apps, and emails that operate on any device. Many companies, like Facebook, eBay, Mozilla, Adobe, and even Disney, use it. This framework is based on bootstrap, which is similar to SaaS.
3 min read
Foundation CSS Callout Basics
Foundation CSS is an open-source and responsive front-end framework created by ZURB in September 2011 that makes it simple to create stunning responsive websites, apps, and emails that operate on any device. Many companies, like Facebook, eBay, Mozilla, Adobe, and even Disney, use it. This framework is based on bootstrap, which is similar to SaaS.
2 min read
Foundation CSS Reveal Basics
The Foundation CSS is an open-source and responsive front-end framework created by ZURB in September 2011 that makes it simple to create stunning responsive websites, apps, and emails that operate on any device. Many companies, like Facebook, eBay, Mozilla, Adobe, and even Disney, use it. This framework is based on bootstrap, which is similar to Sa
2 min read
Foundation CSS Card Basics
Foundation CSS is an open-source & responsive front-end framework built by ZURB foundation in September 2011, that makes it easy to layout stunning responsive websites, apps, and emails that appear amazing & can be accessible to any device. In this article, we will learn about Card Basics. A Foundation CSS Card generally contains a header,
2 min read
Foundation CSS Slider Basics
Foundation CSS is the frontend framework of CSS that is used to build responsive websites, apps, and emails that work perfectly on any device. It is written using HTML, CSS, and Javascript and is used by many famous companies like Amazon, Facebook, eBay, etc. It uses packages like Grunt and Libsass for fast coding and controlling and Saas compiler
2 min read
Foundation CSS Button Basics
Foundation CSS is the frontend framework of CSS that is used to build responsive websites, apps, and emails that work perfectly on any device. It is written using HTML, CSS, and Javascript and is used by many famous companies like Amazon, Facebook, eBay, etc. It uses packages like Grunt and Libsass for fast coding and controlling and Saas compiler
2 min read
Foundation CSS Switch Basics
Foundation CSS is an open-source and responsive front-end framework built by ZURB foundation in September 2011, that makes it easy to design beautiful responsive websites, apps, and emails that look amazing and can be accessible to any device. It is used by many companies such as Facebook, eBay, Mozilla, Adobe, and even Disney. The framework is bui
3 min read
Foundation CSS Tables Basics
Foundation CSS is an open-source and responsive front-end framework created by ZURB in September 2011 that makes it simple to create stunning responsive websites, apps, and emails that operate on any device. Many companies, like Facebook, eBay, Mozilla, Adobe, and even Disney, use it. This framework is based on bootstrap, which is similar to SaaS.
2 min read
Foundation CSS Dropdown Basics
Foundation CSS is an open-source and responsive front-end framework created by ZURB in September 2011 that makes it simple to create stunning responsive websites, apps, and emails that operate on any device. Many companies, like Facebook, eBay, Mozilla, Adobe, and even Disney, use it. This framework is based on bootstrap, which is similar to SaaS.
2 min read
Foundation CSS Tabs Basics
Foundation CSS is an open-source and responsive front-end framework created by ZURB in September 2011 that makes it simple to create stunning responsive websites, apps, and emails that operate on any device. Many companies, like Facebook, eBay, Mozilla, Adobe, and even Disney, use it. The framework is based on bootstrap, which is similar to SaaS. T
3 min read