SwitchUp SwitchUp Ranked Best Coding Bootcamps 2025

HTML Document Structure

Written in HTML CSS Development
updated on 3 Jan 2024

When we write an HTML file for a website, there is a standard structure that we must follow. You will be needing this when you develop your assignments locally on your computer.

The basic structure of a standard HTML file looks like this.
language=>HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <!-- sets the character set your document should use to utf-8 --> <title>A basic page</title> <!-- title tag defines what is shown on the tab of the browser --> <!-- you can also put descriptions and keywords in here that you want to appear on search results --> </head> <body> This is a page about the structure of HTML. <!-- This is a comment, comments use this syntax --> <!-- Only content inside the body tag will display on the browser --> </body> </html>
Let's break down each individual part for you to understand.
language=>HTML <!DOCTYPE html>
You start by writing the <!DOCTYPE html> tag, DOCTYPE means DOCument TYPE, this gives instruction to the browser that the rest of the file is HTML.
language=>HTML <html lang="en"> ... </html>
Then you create a <html> tag, all contents will be enclosed inside this tag. Notice the attribute lang="en" in the opening tag? This lets the browser know the content is in English. You don't necessarily have to add this to your html file, but it does help services as Google understand better the demographic your website is targeting.
language=>HTML <head> ... </head>
The <head> tag is used to define things that are important to the browser, i.e. metadata, and resources that help the browser display the page correctly.
language=>HTML <meta charset="utf-8" >
The <meta> tag is for adding meta information. The first meta information we want to add is the character set. Character sets are libraries of human language characters. There are many libraries but "utf-8" is a character set that includes pretty much all characters from all the human languages.

Now your page can handle pretty much any textual content you put on it. There is no reason not to set this. Notice the meta tag doesn't have a closing tag, this is because this tag does not expect to contain content. This type of element is called a self-closing element, we will encounter more of them in later sections.
language=>HTML <title>A basic page</title>
The <title> tag is the text that shows up on the tab of your web browser. It is also the title that gets displayed when your page shows up on Google searches. Make sure your title is relevant to the information on your page. As a best practice, keep it to within 30 characters.
language=>HTML <body> This is a page about the structure of HTML. <!-- This is a comment, comments use this syntax --> <!-- Only content inside the body tag will display on the browser --> </body>
Finally, the meat of our sandwich. The <body> tag contains all the content to be displayed on the browser. This is where you put all your paragraphs, headers, images, etc. This hierarchical structure of the HTML file is called the document object model (DOM).

Let's do some more exercises on HTML to finish this section.

Exercise - Only do the following exercises on RemoteCode. If the links are giving you errors, you need to click https://www.altcademy.com/api/v2/autologin_remotecode?coursename=webdesignium to authorize your browser. If it still doesn't work, please message us.

Trusted by

Students and instructors from world-class organizations

Join the upcoming Cohort #120

Enroll for December 7th, 2026