About 1210 letters

About 6 minutes

#Structure of an HTML Document

Here is a basic example:

<!DOCTYPE html> <html> <head> <title>Page Title</title> <meta charset="utf-8"/> </head> <body> <h1>This is a Heading</h1> <p>This is a paragraph</p> </body> </html>
  • <!DOCTYPE html> declares that this is an HTML5 document
  • <html> ... </html> is the root element that contains the entire content of the document
  • <head> ... </head> is the document head, used for setting the page title, styles, scripts, etc.
  • <body> ... </body> is the document body, which is the visible part of the page

Note that <meta charset="utf-8"/> sets the character encoding and should match the encoding used by your editor when saving the file. Most modern editors default to UTF-8.

Create a new text file, copy the above code into it and save it. Then rename the file extension to .html and open the file in a browser.

It will look like this:

Page Title

This is a Heading

This is a paragraph

Created in 5/16/2025

Updated in 5/16/2025