Computer scienceFrontendHTMLHTML IntroIntroduction to HTML

HTML page structure

3 minutes read

Programming is not as mechanical and alien as it may seem: in many respects, it is similar to the human world. This is very easy to notice if you look at the structure of HTML pages, which contains elements like <head> and <body>. Making a site is thus a process of creation, and as a creator, you need to be familiar with all the necessary building blocks. This topic aims to explain the structure of an HTML document, ensuring you can confidently craft the skeleton of a web page.

Basic tags in HTML

In the realm of HTML, certain tags are foundational to the architecture of a webpage. These tags orchestrate the content and structure, providing a framework for web browsers to interpret and display the data. A typical HTML document is segmented into three core sections: <html>, <head>, and <body>.

Take a look at the code of a simple HTML page:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Page title</title>
  </head>
  <body>
    <h1>This is a heading</h1>
    <p>This is a paragraph</p>
  </body>
</html>

Upon saving this snippet as an .html file and viewing it through a web browser, the page will look like this:

The HTML page with the heading and paragraph

This looks quite basic, but with HTML you can do much more: customize the structure of the text, manage its visual presentation, and display paragraphs, forms, pictures, titles, and tables. HyperText Markup Language allows you to format texts, which makes them friendlier to Internet users. It is much more convenient to read text with clear and logical markup rather than plow through unstructured text.

Let's get back to the code from the previous example and consider the listed tags in more detail.

  • The <!DOCTYPE> declaration is crucial as it informs the browser of the HTML version being used, ensuring the document adheres to the appropriate HTML standards. Unlike most HTML tags, it does not require a closing tag.

  • The <meta charset="utf-8"> tag specifies the character encoding for the document. Omitting this can lead to incorrect character rendering in some browsers, especially for non-ASCII characters.

  • The <html> tag encapsulates the entire HTML document, essentially declaring the start and end of the HTML content.

  • The <head> tag acts as a container for metadata, which includes information used by browsers and search engines, such as CSS links and scripts.

  • Within <head>, the <title> tag defines the title of the document, which appears on the browser tab or title bar. It's a small but vital element for SEO and user experience.

  • The <body> tag defines the page content area. It wraps the content displayed in the main browser window;

  • The <h1> tag is typically used for the main heading of a page, and it's important for both SEO and accessibility. Similarly, the <p> tag is used to define paragraphs of text.

Basic HTML Page Structure

Here is a visualization of the basic HTML page structure:

The HTML page structure tht represents nesting princip of HTML elemets

As you can see, this structure bears a resemblance to our anatomy. Hopefully, this analogy will help you understand HTML better.

Conclusion

Just as humans have more complex systems beyond the basic anatomy, web pages can also contain different elements and tags within the <body> that make them unique and functional. However, no matter how complex a web page gets, its fundamental structure remains consistent. Understanding this foundation is the first step in creating any web page and will serve as a guide as you learn more about HTML and web development.

1552 learners liked this piece of theory. 19 didn't like it. What about you?
Report a typo