The four essential parts of the HTML document
An HTML document comprises the four parts shown below. Click on the headings for a full explanation. In the section underneath you can see how they look when they are put together.
- The HTML document starts with the 'DOCTYPE' declaration. Note the use of uppercase.
- The DOCTYPE declaration does not have a closing tag.
- The DOCTYPE declaration tells the browser which version of HTML is being used.
Next, just after the DOCTYPE, is the HTML 'opening' tag. Down the bottom, at the very end of the document, is the matching 'closing' tag. These tags mark the beginning and end of the document. With the exception of the DOCTYPE, everything goes between them.
Note that it usually includes the language attribute, which sets the default language for the whole page. This example is for the English language.
<html lang="en"> </html>
The 'head' element is near the top, just after the HTML opening tag. It is defined by 'head' opening and closing tags. The head section is not visible on the web page. The contents of the head section are discussed in the next lesson.
The 'body' element lives under the 'head' section. It is defined by 'body' opening and closing tags. This section contains the visible content of the web page.
Putting it all together
This is what you get when you put all the above bits together – the skeleton of an HTML document.
<!DOCTYPE html> <!--DOCTYPE declaration--> <html lang="en"> <!--start of HTML document--> <head> <!--start of 'head' element--> (content of 'head' section) </head> <!--end of 'head' element--> <body> <!--start of 'body' element--> (visible content of web page) </body> <!--end of 'body' element--> </html> <!--end of HTML document-->