HTML Website Structure: Basic HTML Document Explained

Introduction

  • Every HTML page follows a basic structure.
  • This structure tells the browser how to display the content.
  • Without it, the webpage may not work correctly.

This basic HTML page structure is also known as an HTML skeleton or HTML boilerplate template.

In this lesson, you will learn the basic structure of an HTML document and understand what each part does.

What You’ll Learn in This Lesson

  • Basic structure of an HTML document
  • Purpose of <!DOCTYPE html>
  • Meaning of <html>, <head>, and <body>
  • Where content is placed in HTML

Basic HTML Document Structure (HTML Boilerplate)

The basic HTML structure is sometimes called the HTML boilerplate or HTML skeleton.

It is the standard starting template used to create every HTML webpage.

Developers usually start every project using this basic structure:

<!DOCTYPE html>
<html>
<head>
    <title>My First Web Page</title>
</head>
<body>
    <h1>Hello World</h1>
    <p>This is my first webpage.</p>
</body>
</html>

Explanation of Each Part

🔹 <!DOCTYPE html>

  • Tells the browser this is an HTML5 document
  • Must be written at the top of the file

🔹 <html>

  • The root element of the webpage.
  • Everything inside the webpage is inside this tag.

🔹 <head>

  • Contains page information
  • Not visible on the web page
  • Commonly used for:
    • Page title
    • Meta information
    • CSS links (later)
    • Scripts (later)

🔹 <title>

  • Sets the title of the web page
  • Appears in the browser tab

🔹 <body>

  • Contains everything visible on the webpage.
  • Text, images, links, forms, etc.

Why HTML Structure Is Important

Every HTML page must follow a proper structure so that browsers can understand and display the content correctly.

A correct HTML structure helps:

• Browsers render the page properly
• Search engines understand the webpage
• Developers keep the code organized

Even a simple webpage should follow the standard HTML structure.

Basic Structure Diagram

This diagram helps you understand the basic structure of an HTML document.

HTML Document
│
├── head
│   └── title
│
└── body
    ├── headings
    ├── paragraphs
    └── images

How to Create Your First HTML Page

You can follow these steps to create your first HTML page.

  • Step 1: Open Notepad or any code editor
  • Step 2: Copy the HTML structure
  • Step 3: Save the file as index.html
  • Step 4: Open it in a browser

How the Output Looks in the Browser

When you open the HTML file in a web browser, the output will look like this:

Output:

What Happens When You Open the File?

When you open the HTML file in a browser, the browser reads the HTML code from top to bottom and displays the content inside the <body> tag.

The <h1> tag appears as a large heading, and the <p> tag appears as normal paragraph text.

Everything inside the <body> section is visible on the webpage.

Important Rules to Remember

Remember these important rules:

  • The HTML document should always start with <!DOCTYPE html>
  • HTML tags usually come in pairs
  • Tags must be properly closed
  • Structure should be followed for every page
  • File should be saved with .html extension

Common Beginner Mistakes

  • Forgetting <!DOCTYPE html>
  • Writing content outside <body>
  • Not closing tags properly
  • Misspelling tag names

FAQs

What is the basic structure of an HTML document?

The basic structure of an HTML document normally includes <!DOCTYPE html>, the <html> root element, a <head> section for metadata, and a <body> section for the visible page content.

What is <!DOCTYPE html> in HTML?

<!DOCTYPE html> is the document type declaration. It tells the browser to use the modern HTML parsing mode when displaying the page. It should be placed at the beginning of an HTML document.

What is the purpose of the <html> tag?

The <html> element is the root element of an HTML document. It contains the document’s <head> and <body> sections. It is also a good practice to specify the document language, for example:

<html lang="en">

What is the difference between <head> and <body> in HTML?

The <head> contains information about the document, such as the page title, metadata, stylesheets, and other resources. The <body> contains the content that users see and interact with on the webpage.

What is the purpose of the <title> tag?

The <title> element defines the title of the HTML document. It is commonly displayed in the browser tab and can also be used by search engines when generating search-result titles.

Is the <head> section visible on a webpage?

The contents of the <head> are generally not displayed as page content. It contains metadata and resources that browsers and other software use to process the webpage.

Why should I use lang="en" in the <html> tag?

The lang attribute identifies the primary language of the document. For example, lang="en" indicates English. Providing the correct language helps browsers, search engines, and assistive technologies understand the page correctly.

Can I create an HTML page without CSS or JavaScript?

Yes. HTML can be used by itself to create the structure and content of a webpage. CSS is used to control presentation and layout, while JavaScript is commonly used to add behavior and interactivity.

What is an HTML boilerplate?

An HTML boilerplate is a basic HTML document template containing the essential structure needed to start a webpage. It usually includes <!DOCTYPE html>, <html>, <head>, and <body>.

What is the difference between HTML5 and the current HTML standard?

HTML5 was a major generation of HTML that introduced many modern features. Today, HTML is maintained as a Living Standard rather than as separately numbered versions. This means the standard is continuously updated instead of being released as HTML 6, HTML 7, and so on.

Practice Tasks

Now that you understand the basic structure of an HTML document, try the following exercises to test your knowledge.

Try the following practical tasks to test your understanding of the HTML structure.

Task 1: Create Your First HTML Page

Create an HTML file with the basic structure and display the following text in the browser:

  • Heading: My First Website (Use <H1></h1>)
  • Paragraph: I am learning HTML on DivPHP Tutorials. (Use <P></P>)

Task 2: Change the Page Title

Modify the <title> tag of your HTML document.

Set the page title to:

HTML Practice Page

Then open the file in your browser and check the title in the browser tab.

Task 3: Add Another Paragraph

Inside the <body> section, add another paragraph below the first one with the text:

HTML is easy to learn.

Task 4: Add Two Headings

Inside the <body> tag, add:

  • One <h1> heading
  • One <h2> heading

Example text:

<h1>Welcome to HTML</h1>
<h2>This is my practice page</h2>

Open the file in your browser and see how the headings appear.

Notes

🔹 HTML Tags Are Not Case-Sensitive

HTML tags are not case-sensitive. This means you can write tags in uppercase or lowercase.

For example, the following tags will work in the same way:

<h1>Hello</h1>
<H1>Hello</H1>

However, it is recommended to use lowercase tags, because this is the modern HTML coding standard.

🔹 About the Practical Tasks

The practical tasks in this lesson are basic exercises to help you understand the HTML structure.

In the upcoming tutorials, you will learn these elements in more detail, including headings, paragraphs, images, and other HTML tags.

In the next tutorial, we’ll learn about HTML Headings & Paragraphs.

Related Tutorials

  • HTML Introduction

    ✦ Daily Motivation Challenges are part of the process. Keep experimenting and keep learning. 👋 First time learning web development?We recommend starting with our Start Here guide before continuing this lesson. It will help you understand the learning path for HTML, CSS, PHP, and WordPress. Introduction HTML stands for HyperText Markup Language. It is the…

  • HTML Headings & Paragraphs

    ✦ Daily Motivation Challenges are part of the process. Keep experimenting and keep learning. Introduction Headings and paragraphs are among the most commonly used elements in HTML. They help structure the content and make web pages readable and well-organized. Headings are used to define titles and sections of a webpage, while paragraphs are used to…

  • HTML Text Formatting

    ✦ Daily Motivation Challenges are part of the process. Keep experimenting and keep learning. Introduction HTML provides several tags that allow developers to format text on a webpage. Text formatting helps highlight important words, emphasize content, and improve the readability of the page. Using text formatting elements, you can make text bold, italic, underlined, highlighted,…

  • HTML Links

    ✦ Daily Motivation Challenges are part of the process. Keep experimenting and keep learning. Introduction HTML links are used to connect one page to another page. They allow users to move between different web pages, websites, or sections of the same page. Links are a fundamental part of the web. Without links, browsing the internet…

  • HTML Images

    ✦ Daily Motivation Challenges are part of the process. Keep experimenting and keep learning. Introduction Images are an important part of any webpage. They make content more attractive, engaging, and easier to understand. In HTML, images are used to display pictures such as photos, icons, logos, and graphics on a webpage. Adding images helps improve…

  • HTML Lists

    ✦ Daily Motivation Challenges are part of the process. Keep experimenting and keep learning. Introduction HTML lists are used to display items in an organized way. They help structure content clearly and make it easier for users to read and understand information. Lists are commonly used in menus, steps, features, and grouped data on websites.In…