Are you an aspiring web developer just starting out your journey? Learning about the HTML document structure and its different types of elements is the first step in your journey.
Getting a clear understanding of HTML document structure will not only help you in writing code but will also make you familiar with various HTML tags and elements used in framing a basic HTML page. In today’s article, we will be discussing HTML document structure, its various types, examples, and much more. So, without wasting any time let’s get started.
Also Read: Cloud Architecture – Benefits & Components
HTML Document – Key Takeaways
- Getting familiar with the concept of HTML documents.
- Understanding different HTML document Tags and elements.
- Learning the implementation of HTML document structure with the help of detailed examples.
What Is An HTML Document?
Before moving further, It is essential to understand the structure of an HTML document. An HTML document is like the blueprint of a web page; it tells the browser about how to display content like text, images, and links. Just as making a car requires assembling of different parts, similarly an HTML document is built from different parts, each having a unique role.Â
Let us move further to understand the structure of an HTML document and how to implement it for making a web page.
Also Read: System Administrator
Structure Of An HTML Document
When you open a webpage in your browser, you might have seen different web pages being structured differently, this is the result of an HTML document structure. The structure of an HTML document is like the skeleton of a webpage, as it defines how content is to be organized and displayed. To create a well-structured webpage, it’s essential to understand the various components that make up an HTML document. Each component plays a crucial role in telling the browser how to interpret and present the content. Let’s explore these components one by one.
Tag | Use | Syntax |
<doctype> | Declares the document type and version of HTML used. | <!DOCTYPE html> |
<html> | Root element that wraps all the content of the HTML document. | <html> … </html> |
<head> | Contains meta-information about the document, such as the title and links to CSS files. | <head> … </head> |
<title> | Sets the title of the webpage, which appears in the browser tab. | <title>Page Title</title> |
<meta> | Provides metadata like character set, author, and description for the document. | <meta charset=”UTF-8″> |
<link> | Links external resources like CSS files to the document. | <link rel=”stylesheet” href=”styles.css”> |
<body> | Contains all the visible content of the webpage. | <body> … </body> |
<main> | Wraps the main content of the webpage, ensuring it is easy to differentiate from other parts like sidebars or footers. | <main> … </main> |
<footer> | Defines the footer section of the webpage, usually containing contact info, copyrights, or links. | <footer> … </footer> |
<section> | Used for grouping related content together within the webpage. | <section> … </section> |
<aside> | Contains content related to the main content, like sidebars or ads, but not part of the main content. | <aside> … </aside> |
<nav> | Wraps navigation links, making it easier for users to move between different sections or pages. | <nav> … </nav> |
<div> | A container used to group elements together for styling or scripting. | <div> … </div> |
Also Read: Website Layout Design – (+10 Page Layout Design Ideas)
1. `<!DOCTYPE html> Tag`
The very first line of any HTML document is the `<!DOCTYPE html>` declaration. This line might look simple, but it serves an important purpose. The `<!DOCTYPE>` declaration tells the web browser about what version of HTML is used in the framing of the document.Â
For modern web development, we generally use HTML5, and by using this declaration the browser ensures that it is using the latest standards to interpret the document. Without this declaration, the browser might interpret the page incorrectly.
2. `<html>` Tag
The `<html>` tag is the next one being used after `<!DOCTYPE html>` declaration and is basically used for wrapping the entire content of your webpage.Â
Everything you see on the webpage, from the text and images to the links and forms, is enclosed within this `<html>` tag. The `<html>` element is the root element of your HTML document, which means that all other elements are its children. It tells the browser that the content within these tag is an HTML code. Without the `<html>` tag, the browser wouldn’t know where the HTML content starts and ends.
Also Read: 10 Best Information Technology Companies In World
3. `<head>` Tag
Inside the `<html>` tag, the first major section is the `<head>` element. The `<head>` section contains meta-information about the webpage that is not directly displayed on the page itself. For example, it includes the title of the page, which appears in the browser tab, and links to external resources like CSSÂ and Javascript.Â
It can also contain meta tags that provide information about the webpage to search engines. While the `<head>` section is not visible to the user, it’s still crucial and necessary for the proper functioning of the webpage.
4. `<title>` Tag
Within the `<head>` section, you’ll find the `<title>` tag. The `<title>` tag is essential because it defines the title of the webpage, which appears in the browser. A clear and descriptive title help users to quickly identify what the page is about, and it’s also important for search engine optimization. For example, if you’re building a webpage about top racing cars, a title like “Furious Racing Car’s Of 2024” is both informative and engaging.
5. `<meta>` Tag
Another important component within the `<head>` section is the `<meta>` tag. The `<meta>` tag provides metadata about the HTML document, such as the character set, author description, and more.Â
These meta tags are not visible on the webpage but are vital for SEO and responsive design. For example, the `<meta charset=”UTF-8″>` tag specifies the character encoding, ensuring that all characters on the page display correctly.
6. `<link>` Tag
The `<link>` tag is also found in the `<head>` section and is used to link external resources to the HTML document, such as adding CSS and icons. For example, if you want to apply a specific style to your whole webpage, you can use the `<link>` tag to connect your HTML document to an external CSS file. This will help you to keep your HTML clean and separates the content from the styling.
7. `<body>` Tag
Following the `<head>` section is the `<body>` element. The `<body>` tag encloses all the visible content of your webpage, including text, images, videos, links, and forms. Whatever you see on the webpage is inside the `<body>` tag.Â
This is where you structure the actual content that users interact with. Without the `<body>` element, there would be no content displayed on the webpage, making it one of the most critical parts of an HTML document.
8. `<header>` Tag
The `<header>` tag is often found within the `<body>` section and is used to define the header of the webpage. This usually contains the website’s logo, navigation menu, and other introductory content.Â
The header is basically the first thing users see when they visit a webpage, so it’s essential to make it clear and visually appealing.
9. `<main>` Tag
The `<main>` element is used to wrap the main content of the webpage. This tag is important because it helps search engines and screen readers to understand the core content of the page.Â
Only one `<main>` element should be used per page, and it should not contain content that is repeated across multiple pages, like headers or footers.
10. `<footer>` Tag
The `<footer>` tag is used to define the footer of the webpage. This section usually contains information like copyright notices, links to privacy policies, and contact information.Â
The footer is the last thing users see on the page, so it’s a good place to include important links or information.
11. `<section>` Tag
The `<section>` tag is used to define sections within the body of the HTML document. Each `<section>` represents a grouping of content, basically with its own heading. For example, on a news website, each article could be wrapped in its own `<section>` tag. This generally helps in organizing the content and makes the webpage more readable and accessible.
12. `<aside>` Tag
The `<aside>` tag is used to define content that is related to the main content but isn’t part of it. For example, sidebars, quotes, or advertisements are often placed within an `<aside>` element. This tag generally helps in separating the supplementary content from the main content and makes the webpage more organized.
13. `<nav>` Tag
The `<nav>` element is used to define the navigation links on the webpage. These links usually allow users to move between different pages or sections of the website. Proper use of the `<nav>` element makes it easier for users to navigate your site and improves accessibility for screen readers.
14. `<div>` Tag
The `<div>` tag is a flexible element used to group together the different parts of the webpage. It doesn’t add any specific meaning to the content but is commonly used with CSS to apply styles or with JavaScript to manipulate content. The `<div>` element is essential for organizing and styling your webpage, especially when working with complex layouts.
Some Other HTML Important Tags
Apart from the tags listed above, there are many other HTML tags used in designing and structuring web pages. Using these elements not only enhances the overall look and feel of the webpage but also improves the site’s SEO ranking and drives more traffic to it. Let us understand some of the tags and their uses with the help of the table listed below-
HTML Document – Important Tags | ||
Tag | Use | Syntax |
<h1> to <h6> | Defines headings, with <h1> being the most important and <h6> the least. | <h1>Heading</h1> to <h6>Heading</h6> |
<p> | Defines a paragraph of text. | <p> … </p> |
<ul> | Creates an unordered list In HTML. | <ul> … </ul> |
<ol> | Creates an ordered (numbered) list of items. | <ol> … </ol> |
<li> | Defines a list item within an ordered or unordered list. | <li> … </li> |
<a> | Creates a hyperlink to another webpage or within the same page. | <a href=”url”>Link Text</a> |
<img> | Embeds an image into the webpage. | <img src=”image.jpg” alt=”Description”> |
<table> | Creates a table to organize data in rows and columns. | <table> … </table> |
<b> | Makes text bold | <b> … </b> |
<i> | Makes text italic | <i> … </i> |
<u> | Underlines text. | <u> … </u> |
HTML Document Example
After getting familiar with the HTML document structure and the various elements used in it, let us understand its practical implementation with the help of HTML document example-
HTML Document Example |
<!DOCTYPE html>
<html lang=”en”> <head> Â Â Â Â <meta charset=”UTF-8″> Â Â Â Â <meta name=”description” content=”A simple example of HTML document structure”> Â Â Â Â <title>PW Skills Webpage</title> Â Â Â Â <link rel=”stylesheet” href=”styles.css”> </head> <body> Â Â Â Â <header> Â Â Â Â Â Â Â Â <h1>Welcome to PW Skills Webpage</h1> Â Â Â Â Â Â Â Â <nav> Â Â Â Â Â Â Â Â Â Â Â Â <ul> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <li><a href=”#home”>Home</a></li> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <li><a href=”#about”>About</a></li> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <li><a href=”#contact”>Contact</a></li> Â Â Â Â Â Â Â Â Â Â Â Â </ul> Â Â Â Â Â Â Â Â </nav> Â Â Â Â </header> Â Â Â Â <main> Â Â Â Â Â Â Â Â <section id=”home”> Â Â Â Â Â Â Â Â Â Â Â Â <h2>Home</h2> Â Â Â Â Â Â Â Â Â Â Â Â <p>This is the homepage of PW Skill website. Here, you can find information about our company and our goals.</p> Â Â Â Â Â Â Â Â </section> Â Â Â Â Â Â Â Â <section id=”about”> Â Â Â Â Â Â Â Â Â Â Â Â <h2>About PW Skills</h2> Â Â Â Â Â Â Â Â Â Â Â Â <p>PW Skills is a branch of the parent company Physics Wallah, it is an edtech platform providing various free and paid certification courses.</p> Â Â Â Â Â Â Â Â <article> Â Â Â Â Â Â Â Â Â Â Â Â <h2>Latest Blog Post</h2> Â Â Â Â Â Â Â Â Â Â Â Â <p>Here is our latest blog post:</p> Â Â Â Â Â Â Â Â Â Â Â Â <blockquote> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â “Learning HTML is the first step in becoming a web developer. It’s important to understand the structure of an HTML document.” Â Â Â Â Â Â Â Â Â Â Â Â </blockquote> Â Â Â Â Â Â Â Â </article> Â Â Â Â Â Â Â Â <aside> Â Â Â Â Â Â Â Â Â Â Â Â <h2>Related Links</h2> Â Â Â Â Â Â Â Â Â Â Â Â <ul> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <li><a href=”https://www.pwskills.com”>PWskills</a></li> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <li><a href=”https://www.pw.live”>Parent page</a></li> Â Â Â Â Â Â Â Â Â Â Â Â </ul> Â Â Â Â Â Â Â Â </aside> Â Â Â Â </main> Â Â Â Â <footer> Â Â Â Â Â Â Â Â <p>© 2024 PW Skills. All rights reserved.</p> Â Â Â Â Â Â Â Â <p>Contact: <a href=”mailto:pwskills@gmail.com”>PW Email ID</a></p> Â Â Â Â </footer> </body> </html> |
Output-Â |
Learn Web Designing With PW Skills
Enroll in our comprehensive full stack developer course to learn everything related to front-end as well as back-end development in a beginner-friendly manner.
This 6-month-long job assistance program comes up with a detailed course starting from the foundational topics and then covering the advanced ones. Not only this but it also offers benefits like- Expert mentorship, 100% job assistance guarantee, daily practice sheets, 10+ practical projects, and much more.
Limited seats left! Visit PWskills.com today and start your journey with us!
DOM in JavaScript FAQs
Can an HTML document have multiple tags?
No, an HTML document cannot have multiple tags. Each HTML document must have exactly one tag that contains all the visible content of the webpage.
What is the purpose of the tag?
The tag is used to control the layout on mobile browsers. The setting ensures that the page fits the screen width of the device and the initial zoom level. This tag is crucial for making your website mobile-friendly and highly accessible.
Is it necessary to use closing tags in HTML?
In HTML5, some of the tags are self-closing and do not require a closing tag. However, most tags like
, and