SA-21/06, C-11, Asapur, Varanasi, UP support@kamaldnp.com +91 8318013442
HTML
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
Final Test — Certificate ₹10
Try this code live
Lesson 3 of 35

HTML Basic Structure: Doctype, Head, Body Explained

3 min read · Free · No login needed

Every HTML page follows the same basic structure. Once you learn it, you can read any web page's code and understand where things belong.

Diagram — see how it fits together
Infographic: structure of a basic HTML document

The five parts of a page

  • <!DOCTYPE html> — the first line. It tells the browser: this is an HTML5 document. It is not a tag; it is a declaration.
  • <html> — the root element. Everything on the page sits inside it.
  • <head> — information about the page: the title, the character set, links to CSS. Nothing inside the head is shown on the page itself.
  • <title> — the text that appears on the browser tab. It sits inside the head.
  • <body> — everything the visitor actually sees: headings, text, images, links, buttons.

How tags work

Most tags come in pairs: an opening tag like <h1> and a closing tag like </h1>. The content sits between them. A few tags, like <br> and <img>, have no closing tag — they are called empty elements.

Tip: Always close the tags you open, and keep them nested properly — a tag opened inside another tag must close before the outer one closes.

The five parts, explained simply

Think of a page like a letter. <!DOCTYPE html> is the stamp on the envelope — it says what kind of document this is. <html> is the envelope itself, holding everything. <head> is the address written on the envelope — information about the letter, not the letter itself. <title> is the subject line. And <body> is the actual letter — the part people read.

Syntax

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Page title</title>
</head>
<body>
  <h1>Heading</h1>
  <p>Paragraph.</p>
</body>
</html>

The lang="en" part tells the browser the page is in English. It helps screen readers pronounce the words correctly, and it helps search engines understand the page.

Note: The <head> is invisible. Nothing inside it appears on the page. Beginners often put visible text in the head by mistake — if your text is not showing, check that it is inside <body>.
Tip: Indent the tags inside <body> with two spaces. It costs nothing and makes your code much easier to read when the page grows.

Common mistakes

  • Forgetting <!DOCTYPE html> at the top — the browser then guesses, and the page may look different.
  • Putting headings or paragraphs inside <head> instead of <body>.
  • Using two <h1> headings on one page — use only one, for the main heading.
  • Leaving the lang attribute out — it takes seconds to add and helps everyone.

Example explained

  • <!DOCTYPE html> — the first line, a declaration. It tells the browser this is an HTML5 document.
  • <html> ... </html> — the root element. The whole page lives between these two tags.
  • <head> and <title>Page Title</title> — information about the page. The title text appears on the browser tab, and nothing in the head shows on the page itself.
  • <body> ... </body> — everything the visitor sees: the heading and the paragraph.
  • <h1>My First Heading</h1> — the main heading of the page. Use only one h1 per page.
  • <p>My first paragraph.</p> — a paragraph of ordinary text under the heading.

Example

Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>
</html>

Output

Output — how it looks in the browser
Output of HTML Basic Structure: Doctype, Head, Body Explained

Try it yourself — live editor

Change the code below and press Run to see the result instantly. No file to save, no login needed.

Result

Frequently asked questions

The questions learners ask most about this lesson — read the question, then open it to see the answer.

1. What are the five parts of an HTML page?

DOCTYPE html, the html root element, head, title, and body. The title appears on the browser tab and the body holds everything visitors see.

2. What does the head element contain?

Information about the page, like the title, the character set, and links to CSS. Nothing inside the head is shown on the page itself.

3. Why does my text not show on the page?

You may have put it inside the head by mistake. Visible text must be inside the body element.

Check yourself — did you get it?

Finished the lesson? Test yourself with 5 quick questions — you get the answer instantly, with the reason for each one.

1. What is the root element of every HTML page?

<html> is the root element — everything on the page sits inside it.

2. What appears on the browser tab?

<title> sits inside <head> and its text appears on the browser tab.

3. Which of these is NOT a tag but a declaration?

<!DOCTYPE html> tells the browser this is an HTML5 document. It is a declaration, not a tag.

4. Where does the visible content of a page go?

<body> holds everything the visitor actually sees — headings, text, images, links, buttons.

5. What does lang="en" tell the browser?

lang="en" tells the browser the page is in English — it helps screen readers pronounce the words and search engines understand the page.

Interview questions — can you answer these?

Read the question first, try to answer it in your own words, then open it to check. These are the questions interviewers actually ask.

1. What is the basic structure of an HTML page?

<!DOCTYPE html> first, then <html> as the root element, <head> for information about the page (title, character set), and <body> for everything the visitor sees.

2. What is the difference between <head> and <body>?

<head> holds information about the page — the title, the character set, links to CSS. Nothing inside <head> is shown on the page. <body> holds everything the visitor actually sees.

3. What does <!DOCTYPE html> do?

It tells the browser that this is an HTML5 document. It is a declaration, not a tag, and it must be the very first line. Without it, the browser guesses, and the page may look different.

Try it yourself — build this

Reading is not enough — now build it yourself. Write the code in the live editor, run it, check the hint if you get stuck, and open the solution only after you have tried.

1. Build the five parts

Create a page with all five parts: <!DOCTYPE html>, <html>, <head>, <title> and <body>. The title must be "My Daily Routine" and the body must have one <h1> and two <p> elements.

Hint: The title goes inside <head>; the heading and the paragraphs go inside <body>. Do not forget <!DOCTYPE html> at the very top.
Open the live editor
Show solution
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Daily Routine</title>
</head>
<body>
<h1>My Daily Routine</h1>
<p>I wake up at 6 AM and study HTML for one hour.</p>
<p>In the evening I practise what I learned and build a small page.</p>
</body>
</html>

Why learn this yourself — and not just ask AI?

AI can write code for you, but it cannot think for you. When you learn HTML yourself, your brain builds the real skill: you understand why a page looks the way it does, you can fix it when it breaks, and you can answer it in an exam or an interview without help. That is the skill that gets you a job — not a copied answer.

Get certified — just ₹10

Finish all 35 lessons, pass the test (80%), pay ₹10 and get your certificate.

Take the test

Prefer watching? Video courses teach the same topics step by step.

Go further with a full course

Free tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.

WordPress Website Development Course (10 Days)
₹399
View
Full Stack PHP Development Course 2026
₹3,000
View
Advanced Cyber Security Industrial Training
₹5,000
View
Browse all courses
HTML — Lessons
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
Final Test — Certificate ₹10

🤖 KAMALDNP AI Assistant

Ask about courses, website & more

Hi! I'm KAMALDNP AI Assistant. Ask me about our courses, website features, or anything else! 😊
Please wait 5s...
🤖 KAMALDNP Assistant ✕

Request human callback:

🔐 Login Required
✕

Please log in to download. You will stay on this page after logging in!

New here? Register now →