Learn the essential structure of every HTML document — the <html>, <head>, and <body> tags.
To write an HTML program that demonstrates the correct use of the <html>, <head>, and <body> tags — the foundational structure of every web page.
Every HTML document follows a basic structure that consists of three main tags:
<html> tag is the root element of an HTML page. The <head> tag contains metadata (information about the page), and the <body> tag contains the visible content that users see.
| Tag | Purpose | What it Contains |
|---|---|---|
<html> |
Root element of the HTML document | All other HTML elements (head and body) |
<head> |
Contains metadata about the document | Title, character set, CSS styles, scripts, meta tags |
<body> |
Contains the visible content of the page | Headings, paragraphs, images, links, forms, etc. |
<html>, <head>, and <body> tags structure the document.| Tag | Common Elements Inside | Purpose |
|---|---|---|
<head> |
<title>, <meta>, <link>, <style>, <script>
|
Sets page title, character encoding, CSS styles, and JavaScript |
<body> |
<h1> to <h6>, <p>, <div>, <img>, <a>, <ul>, <ol>, <table>, <form>
|
Displays all visible content on the page |
<html> |
<head> and <body> |
Wraps the entire document |
| Mistake | Why It's Wrong | Correct Way |
|---|---|---|
Forgetting the <html> tag |
The browser may still render, but the structure is incomplete | Always wrap your code in <html> tags |
Putting visible content in <head> |
The <head> is for metadata only; content won't display |
Place all visible content inside <body> |
| Missing closing tags | Can break the page layout or cause unexpected behavior | Always close tags: <html>...</html> |
| Nesting tags incorrectly | Invalid HTML structure | Proper nesting: <html><head></head><body></body></html> |
<html> tag is the root element — it encloses all other HTML elements.<head> tag contains metadata (information about the page) that is not displayed directly.<body> tag contains all visible content — what users see in the browser.You have successfully:
<html>, <head>, and <body> tags.<html>, <head>, and <body> tags in the correct order. This is the foundation of all web pages!
<body> — like images, links, tables, or forms. Explore what goes inside the <head> — like CSS styles and JavaScript — to make your pages more interactive and beautiful!
ایک HTML پروگرام لکھنا جو <html>، <head>، اور <body> ٹیگز کے صحیح استعمال کو ظاہر کرتا ہے — ہر ویب صفحے کی بنیادی ساخت۔
ہر HTML دستاویز ایک بنیادی ڈھانچے پر مشتمل ہوتی ہے جس میں تین اہم ٹیگز ہوتے ہیں:
<html> ٹیگ HTML صفحے کا روٹ عنصر ہے۔ <head> ٹیگ میٹا ڈیٹا (صفحے کے بارے میں معلومات) رکھتا ہے، اور <body> ٹیگ ظاہر ہونے والا مواد رکھتا ہے جو صارفین دیکھتے ہیں۔
| ٹیگ | مقصد | اس میں کیا ہوتا ہے |
|---|---|---|
<html> |
HTML دستاویز کا روٹ عنصر | تمام دوسرے HTML عناصر (head اور body) |
<head> |
دستاویز کے بارے میں میٹا ڈیٹا رکھتا ہے | عنوان، کریکٹر سیٹ، CSS اسٹائل، اسکرپٹس، میٹا ٹیگز |
<body> |
صفحے کا ظاہر ہونے والا مواد رکھتا ہے | سرخیاں، پیراگراف، تصاویر، لنکس، فارمز وغیرہ |
<html>، <head>، اور <body> ٹیگز دستاویز کو ڈھانچہ دیتے ہیں۔| ٹیگ | اندر عام عناصر | مقصد |
|---|---|---|
<head> |
<title>، <meta>، <link>، <style>، <script>
|
صفحہ کا عنوان، کریکٹر انکوڈنگ، CSS اسٹائلز، اور JavaScript سیٹ کرتا ہے |
<body> |
<h1> سے <h6>، <p>، <div>، <img>، <a>، <ul>، <ol>، <table>، <form>
|
صفحے پر تمام ظاہر مواد دکھاتا ہے |
<html> |
<head> اور <body> |
پوری دستاویز کو گھیرتا ہے |
| غلطی | یہ کیوں غلط ہے | صحیح طریقہ |
|---|---|---|
<html> ٹیگ بھول جانا |
براؤزر اب بھی رینڈر کر سکتا ہے، لیکن ڈھانچہ نامکمل ہے | اپنے کوڈ کو ہمیشہ <html> ٹیگز میں لپیٹیں |
ظاہر مواد کو <head> میں ڈالنا |
<head> صرف میٹا ڈیٹا کے لیے ہے؛ مواد ظاہر نہیں ہوگا |
تمام ظاہر مواد کو <body> کے اندر رکھیں |
| اختتامی ٹیگ غائب | صفحہ کی ترتیب کو توڑ سکتا ہے یا غیر متوقع رویہ کا باعث بن سکتا ہے | ہمیشہ ٹیگز بند کریں: <html>...</html> |
| ٹیگز کو غلط طریقے سے نیسٹ کرنا | غلط HTML ڈھانچہ | صحیح نیسٹنگ: <html><head></head><body></body></html> |
<html> ٹیگ روٹ عنصر ہے — یہ تمام دوسرے HTML عناصر کو گھیرتا ہے۔<head> ٹیگ میٹا ڈیٹا (صفحے کے بارے میں معلومات) رکھتا ہے جو براہ راست ظاہر نہیں ہوتا۔<body> ٹیگ تمام ظاہر مواد رکھتا ہے — جو صارفین براؤزر میں دیکھتے ہیں۔آپ نے کامیابی سے:
<html>، <head>، اور <body> ٹیگز کو ظاہر کرتا ہے۔<html>، <head>، اور <body> ٹیگز صحیح ترتیب میں ہونے چاہئیں۔ یہ تمام ویب صفحات کی بنیاد ہے!
<body> کے اندر مزید عناصر شامل کرنے کی کوشش کریں — جیسے تصاویر، لنکس، ٹیبلز، یا فارمز۔ <head> کے اندر کیا آتا ہے دریافت کریں — جیسے CSS اسٹائلز اور JavaScript — تاکہ آپ کے صفحات مزید انٹرایکٹو اور خوبصورت بن سکیں!