← Back to HTML Course | Chapter 1: Introduction & Basics | Lesson 3 of 11

HTML Basic

basic HTML tags को किसी document के foundational layout blocks की तरह सोचें। जैसे किसी magazine के page में headings, paragraphs, और pictures होते हैं, वैसे ही HTML उन्हें arrange करने के लिए basic tags का उपयोग करती है। ये elements simple, standard structures हैं जो आपके page के core content को बनाते हैं। इन basics के बिना, आपके पास बस एक बड़ी, unreadable, unformatted text की दीवार रह जाएगी।
Syntax
markup
<!DOCTYPE html>
<html>
  <head>
    <title>Page title</title>
  </head>
  <body>
    <!-- visible content -->
  </body>
</html>

Headings और Paragraphs

Headings आपके content की hierarchy को h1 (सबसे महत्वपूर्ण) से लेकर h6 (सबसे कम महत्वपूर्ण) तक व्यवस्थित करते हैं, जबकि paragraphs आपके text के main body को रखते हैं। heading levels को skip करना (सीधे h1 से h4 पर जाना) accessibility और SEO structure, दोनों को नुकसान पहुंचाता है।

Note: अपने document के main title को दर्शाने के लिए per page सिर्फ एक h1 tag का उपयोग करें।
Warning: heading tags का उपयोग सिर्फ text को bold या बड़ा बनाने के लिए न करें; इनका उपयोग सख्ती से headings को structure करने के लिए करें।

उदाहरण: Headings and Paragraphs

markup
<h1>Page Title</h1>
<h2>Section Title</h2>
<p>Paragraph text.</p>

Links और Navigation

Links अलग-अलग वेब pages को anchor tag और href attribute का उपयोग करके आपस में जोड़ते हैं। Links के बिना, web बस अलग-थलग, अनपहुंच द्वीपों की तरह होता। target attribute नियंत्रित करता है कि link same tab में खुले या new tab में।

Note:
  • अपने link text को descriptive रखें ताकि users को पता चले कि click करने पर वे कहां जाएंगे।
  • Accepted attributes:
  • href — URL, #fragment, mailto: या tel: target
  • target — _self | _blank | _parent | _top
  • rel — noopener | noreferrer | nofollow | external ...
  • download — optional filename; navigate करने के बजाय download करता है
Warning: हमेशा अपने links को test करें ताकि यह सुनिश्चित हो सके कि destination path पूरी तरह सही और secure है।

उदाहरण: Links and Navigation

markup
<a href="https://example.com" target="_blank">Visit Example</a>

बुनियादी Image Embedding

img tag आपके page पर images display करता है। text tags के विपरीत, img tag खाली (empty) होता है, यानी इसमें सिर्फ attributes होते हैं और कोई closing tag नहीं होता। हमेशा width और height attributes शामिल करें ताकि ब्राउज़र image लोड होने से पहले उसके लिए जगह reserve कर सके।

Note:
  • web accessibility के लिए हमेशा image tag के अंदर alternate text descriptions शामिल करें।
  • Accepted attributes:
  • src — image file का URL
  • alt — image लोड न होने पर या screen readers द्वारा पढ़े जाने के लिए text alternative
  • width / height — pixels में intrinsic size (integers, बिना units के)
  • loading — lazy | eager
Warning: image paths को सही तरीके से define न करने पर आपके page पर एक broken graphic icon दिखेगा।

उदाहरण: Basic Image Embedding

markup
<img src="photo.jpg" width="300" height="200" alt="A scenic photo">

Line Breaks और Horizontal Rules

br tag नया paragraph शुरू किए बिना text को नई line पर ले जाता है, जबकि hr tag एक horizontal line बनाता है जिसका उपयोग content के असंबंधित हिस्सों को visually अलग करने के लिए किया जाता है।

उदाहरण: Line Breaks and Horizontal Rules

markup
<p>First line<br>
Second line</p>
<hr>

HTML में Comments

<!-- और --> के बीच लिखे गए HTML comments developers के लिए notes होते हैं जिन्हें ब्राउज़र parse करता है लेकिन page पर कभी display नहीं करता, जिससे वे reminders छोड़ने या markup के किसी हिस्से को अस्थायी रूप से disable करने के लिए उपयोगी होते हैं।

उदाहरण: Comments in HTML

markup
<!-- This is a comment, not shown on the page -->
<p>Visible text</p>
Live Example
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
🔒

Chapter Quiz — Complete all 11 topics to unlock

0/11 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.