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.
<!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.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.
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.
<!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.
<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>.<body> with two spaces. It costs nothing and makes your code much easier to read when the page grows.<!DOCTYPE html> at the top — the browser then guesses, and the page may look different.<head> instead of <body>.<h1> headings on one page — use only one, for the main heading.lang attribute out — it takes seconds to add and helps everyone.<!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.<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
Change the code below and press Run to see the result instantly. No file to save, no login needed.
The questions learners ask most about this lesson — read the question, then open it to see the answer.
DOCTYPE html, the html root element, head, title, and body. The title appears on the browser tab and the body holds everything visitors see.
Information about the page, like the title, the character set, and links to CSS. Nothing inside the head is shown on the page itself.
You may have put it inside the head by mistake. Visible text must be inside the body element.
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?
2. What appears on the browser tab?
3. Which of these is NOT a tag but a declaration?
4. Where does the visible content of a page go?
5. What does lang="en" tell the browser?
Read the question first, try to answer it in your own words, then open it to check. These are the questions interviewers actually ask.
<!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.
<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.
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.
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.
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.
<!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>
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.
Finish all 35 lessons, pass the test (80%), pay ₹10 and get your certificate.
Take the testPrefer watching? Video courses teach the same topics step by step.
Free tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.
Browse all coursesAsk about courses, website & more
Request human callback:
Please log in to download. You will stay on this page after logging in!
New here? Register now →