1. HTML Page structure

HTML Page Structure

An HTML document is structured using a set of nested tags. Each tag is enclosed within <…> angle brackets and acts as a container for content or other HTML tags. Let's take a look at a basic HTML document structure:

<!DOCTYPE html>
<html>
<head>
    <title>Document</title>
</head>
<body>
   <!-- content -->
</body>
</html>

A typical HTML Page looks like this:

<html>
<head>
<title>Page title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>

These are the essential elements for a basic HTML document: <!DOCTYPE html><html><head><title></head><body></body></html>


Every HTML page should include at least these essential elements to define the basic layout:

DOCTYPE Declaration

The <!DOCTYPE html> declaration informs the web browser about the HTML version being used.
The latest version is HTML5. But if this changes in the future (maybe 10 years down the line), the doctype declaration will be helpful!

<!DOCTYPE html>

HTML Root Element

The <html> tag is the root element that encapsulates all the content on the page.
The </html> tag marks the end of the <html> section.

<html>

</html>

Head Section

The <head> tag contains metadata and links to external resources like CSS and JavaScript files.
The </head> tag marks the end of the <head> section.

<head>

</head>

Title Tag

The <title> tag sets the title of the web page, which is displayed in the browser's title bar or tab.

<title> Document </title>

Body Tag

The <body> tag contains the visible content of the web page. This is where text, images, and other elements go.
The </body> tag marks the end of the visible content of the web page.

<body>

</body>

Summary

  • The <!DOCTYPE html> tag specifies that the document is an HTML5 document.
  • The <html lang="en"> tag defines the document to be in English.
  • The <head> section contains metadata and the title of the webpage, which appears in the browser's title bar.
  • The <body> section contains the content that will be displayed on the webpage.
  • The h1 and p are two types of tags. We will learn about more tags in the later section