Introduction to HTML Structure: Basic Elements and Syntax

HTML structure plays a crucial role in building web pages. It defines how content is organized and displayed on a webpage. Here is an introduction to the basic HTML structure:

1. Doctype

The Doctype (Document Type Declaration) defines the HTML version that the webpage is using. It should be placed at the beginning of the HTML file.

2. html tag

The html tag is the root element of every HTML file. It encapsulates the entire content of the webpage.

3. head tag

The head tag contains information about the webpage that is not directly displayed on the browser. This is where the title of the page, meta tags, links to CSS and JavaScript files, and various other elements are defined.

4. body tag

The body tag contains all the content that is displayed on the webpage. This is where elements such as text, images, videos, links, and other user interface components are defined.

5. Nested tags

HTML uses a hierarchical structure with opening and closing tags. Child tags are placed inside parent tags. For example, the p tag (paragraph) can contain span tags (inline text), strong tags (bold text), and many other tags.

6. Common tags

HTML provides a range of tags for formatting and displaying content. For example, the h1-h6 tags (headings), p tag (paragraph), img tag (image), a tag (link), and many others.


Here is an example of a complete HTML page structure:

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Webpage</title>
    <link rel="stylesheet" href="styles.css">
    <script src="script.js"></script>
        <h1>Welcome to My Webpage</h1>
                <li><a href="#">Home</a></li>
                <li><a href="#">About</a></li>
                <li><a href="#">Contact</a></li>
            <h2>About Me</h2>
            <p>I am a web developer passionate about creating amazing websites.</p>
            <h2>My Projects</h2>
                <li><a href="#">Project 1</a></li>
                <li><a href="#">Project 2</a></li>
                <li><a href="#">Project 3</a></li>
        <p>&copy; 2022 My Webpage. All rights reserved.</p>

In the above example, we have a complete HTML page with the main elements such as doctype, html tag, head tag and body tag. In the head section, we define the page title, the CSS and JavaScript files to be used. The body section contains elements like header, main, and footer to display the content of the webpage.


By using the correct HTML structure, you can build well-organized, readable, and interactive web pages.