Update appNew update is available. Click here to update.
Last Updated: May 13, 2022

HTML Document Structure

Author Alisha Chhabra


Before diving into the HTML Document Structure, let’s recall what HTML is?

HTML is an abbreviation for HyperText Markup Language, the most frequently used language on the Internet for developing web pages. 

Initially, HTML was created to specify the structure of documents such as headings, paragraphs, lists, and so on to make scientific knowledge more easily shared between researchers. HTML is now commonly used to format web pages using many tags available in the HTML language.

For example, the structure of a human body is determined by the bones; likewise, HTML defines a web page’s structure. 

Source: GCFLearn

Let’s get started with the HTML Document Structure:

Basic HTML Document Structure

HTML, as previously said, is a markup language that uses multiple tags to structure the document. These tags are surrounded by angle braces <Tag Name>. Except for a few tags, the majority of tags contain matching closing tags.  For example, a <head> tag has a closing tag </head>, and a <body> tag has a closing tag </body> tag, and so on. The following template shows a basic structure of a HTML document.

<!DOCTYPE html>
<html lang="en" >

  <meta charset="utf-8">
  <title>Title of the webpage</title>  

  <h1>Heading Tag</h1>
  <p>Paragraph Tag</p>



Tag name



<!DOCTYPE ....>

This tag defines the document type and HTML version.



This tag encloses the whole HTML page and consists mostly of the document header (represented by <head>...</head> tags) and the document body (represented by <body>...</body> tags).



This tag represents the document's header, which includes additional HTML tags such as <title>, <link>, <meta> and so forth.



The <meta> tag is used to define metadata about an HTML document. Metadata is information (data) about the document.



The <title> tag is used within the <head> tag to specify the document’s title.



This tag represents the document's body, which contains additional HTML tags such as <h1>, <div>, <p>, and so on.



This tag represents the heading. There are six different HTML headings from <h1> to <h6>.



This tag represents the paragraph.


The list does not end here; there are several other tags to get started with HTML.

Let's take a closer look at each tag:

The <!DOCTYPE> Declaration

  • The <!DOCTYPE> declaration indicates the document type and assists browsers to display web pages appropriately.
  • It must appear just once, at the top of the page (before any HTML tags).
  • Every HTML document must begin with a <!DOCTYPE> declaration.


Declaration in HTML5:

<!DOCTYPE html>


Since the declaration of <!DOCTYPE> tag is NOT case-sensitive; the below declarations are valid.

<!DOCTYPE html> 
<!DocType html>
<!Doctype html>
<!doctype html>


The <html> tag

  • The <html> HTML element is often known as the root element because it represents the root (top-level element) of an HTML page. All other elements must be descended from this one.
  • Except for the <!DOCTYPE> tag, the <html> tag serves as a container for all other HTML elements.
  • To specify the Web page’s language, always use the lang attribute inside the <html> tag. This is intended to help search engines and browsers.
<html lang="en">


The <head> tag

  • The HTML tag <head> includes machine-readable information (metadata) about the document, such as the title, scripts, and style sheets.
  • The <head> tag is generally used to store information for machine processing rather than for human reading. The <header> element is used to display human-readable information such as top-level headers and listed authors.
  <meta charset="utf-8">
  <title>Document's title</title>


  • The following tags can go inside the <head> tag:
  • <title> (required in every HTML document): This tag defines the document’s title.



<title>Grandma's Heavy Metal Festival Journal</title>


  • <style>:- The HTML element <style> includes style information for a document or a portion of a document.  It includes CSS that is applied to the contents of the document that contains the <style> element.



<style type="text/css">
p {
<p>Hi! I am a paragraph</p>


  • <base>:- The <base> HTML element defines the reference point for all relative URLs in a document. 



<base href="https://www.example.com/">
<base target="_blank">
<base target="_top" href="https://example.com/">


  • <link> :- The <link> tag establishes a connection between the current content and an external resource.



<link href="/media/examples/link-element-example.css" rel="stylesheet">

<p>This text will be red as defined in the external stylesheet.</p>


  • <meta> :- The <meta> element defines metadata about an HTML document. Metadata is data (information) about data.



<!--> A character set is the total amount of distinct characters that a computer program and hardware can support. Character sets are also known as character maps, charsets, and character codes.</!-->
<meta charset="utf-8">


  • <script> :- The <script> tag is used to integrate a client-side script (JavaScript).



<script src="javascript.js"></script>


  • <noscript>:- The <noscript> element specifies alternate content to be presented to users who have scripts deactivated in their browser or are using a browser that does not support script.



  document.write("Coding Ninjas")
<!--> When the above tag fails to display the content owing to the browser's lack of support, the <noscript> tag is used. </!-->
<noscript> Computer Portal </noscript>


The <body> tag

  • The content of an HTML document is represented by the <body> HTML element. 
  • A document can only have one <body> element.
  • The <body> element includes all of the content of an HTML page, including headers, paragraphs, pictures, hyperlinks, tables, lists, and so on.



  <title>Document title</title>
  <p>This is a paragraph</p>


The <p> tag

  • A paragraph is represented by the HTML element <p>. In visual media, paragraphs are often portrayed as blocks of text separated by blank lines or the first-line indentation. In contrast, HTML paragraphs can be any structural grouping of related content, such as images or form fields.
  • Paragraphs are block-level elements, and if another block-level element is processed before the ending </p> tag, they will automatically close.
  • The block-level element begins on a new line. A block-level element always occupies the entire available width (stretches out to the left and right as far as it can).





<!DOCTYPE html>
  <title>Paragraph tag Example</title>

  <h1>The p element</h1>

  <p>This is a paragraph.</p>
  <p>This is a paragraph.</p>
  <p>This is a paragraph.</p>




This is only a brief overview of the HTML Document Structure; there are many more elements and tags to learn in HTML.

Frequently Asked Questions

  1. What is an HTML Document structure?
    The structure of a Web page is described in HTML. HTML is made up of several different elements. HTML elements specify how the content should be displayed in the browser. HTML elements are used to identify different types of information, such as "this is a heading," "this is a paragraph," "this is a link," and so on.
  2. What are the basic five elements of the HTML Document structure?
    Doctype, HTML, title, head, and body are the basic five elements.  These are the tags that go at the top and bottom of an HTML file. This contains title, meta tags, content type, and connections to external pages such as CSS and JavaScript.
  3. What is the difference between HTML and XHTML?
    HTML5 is a version of HTML, whereas XHTML is a mix of HTML and XML. XHTML has its own parsing needs, but HTML doesn't have any and works with what it has. HTML5 uses a less complicated charset and doesn't require type attributes or style elements.

Key Takeaways

To summarise the subject, we looked at the basic tags used in HTML document structure and how they work. The list doesn't stop there; HTML has various tags and elements, which you can refer to in our other articles. Keep a lookout for future posts to help you along your growth path.

Don't be a slacker, Ninja; take part in our Web-development course to set yourself out from the crowd!

Happy Learning Ninja!

Next article
Elements in HTML
Codekaze-June23 India's Biggest Tech Hiring Challenge is LIVE!
Register Now
Go on top