HTML Document Structure
An HTML document follows a basic structure to ensure that browsers can correctly render and understand the content. Below is the standard structure of an HTML5 document.
Basic Structure
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page Title</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is a simple HTML page.</p>
</body>
</html>
Explanation of Parts
<!DOCTYPE html>
Declares the document type and version of HTML. In HTML5, it is simply <!DOCTYPE html>
.
<html>
This is the root element that wraps all the content of the HTML document.
<head>
Contains meta-information about the document, such as title, character encoding, links to stylesheets, and scripts.
<title>
Defines the title of the webpage, shown in the browser tab.
<body>
Holds all the visible content of the web page such as headings, paragraphs, images, links, and more.
Note
Using a well-structured HTML document ensures proper rendering across all browsers and is essential for SEO and accessibility.