Q.Explain the basic structure of an HTML document and the purpose of the <head> and <body> sections.
Every HTML document follows the same basic skeleton:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Visible heading</h1>
<p>Visible paragraph.</p>
</body>
</html>
<!DOCTYPE html> — the first line, telling the browser the document is written in HTML5.
<html> ... </html> — the root element that wraps the entire page; every other element is placed inside it.
<head> ... </head> — holds information about the page that is not displayed in the main browser window. This includes the <title> (the text shown on the browser tab) and links to CSS style sheets. The head describes and sets up the page rather than showing content.
<body> ... </body> — holds all the visible content of the page: headings, paragraphs, images, tables, links, forms — everything the visitor actually sees and interacts with.
In short, the head is for behind-the-scenes information and setup, while the body is for the content the visitor sees.
An HTML document begins with <!DOCTYPE html> and an <html> root element enclosing two sections: the <head>, which holds non-visible page information such as the <title> and links to CSS, and the <body>, which holds all the visible content of the page (headings, paragraphs, images, tables, and more).
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.