Skip to content

Module 01 — Basic HTML Foundations (HTML Ke Core Concepts)


1. What is it? (Ye Kya Hai?)

HTML (HyperText Markup Language) Internet par har ek webpage ka standard structural backbone hota hai. Ye browser ko batata hai ki webpage par kaunsa content kis format aur hierarchy mein display hona chahiye.

HTML ko gehraai se samajhne ke liye iske teen words ko alag-alag dekhte hain:

  • HyperText: Aisa text jisme hyperlinks embedded hote hain. Normal printed kitabon ki tarah aapko line-by-line nahi padhna padta; aap kisi bhi link par click karke ek document se doosre document par instantly jump kar sakte hain.
  • Markup: Text ko special tags (jaise <p>, <h1>, <img>) ke sath annotate karna. Ye tags browser ko batate hain ki ye simple text nahi hai, balki ek heading, ek paragraph ya ek clickable button hai.
  • Language: Ye ek standardized rules aur syntax ka set hai jo WHATWG HTML Living Standard aur W3C dwara define kiya gaya hai, taki Chrome, Firefox, Safari ya Edge sabhi browsers webpage ko ek jaisa render karein.

2. Why do we use it? (Hum Iska Use Kyun Karte Hain?)

Agar HTML na ho, to web browser ko sirf raw text ka binary stream milega. Browser ko ye kabhi pata nahi chal payega ki kaunsi line article ka title hai, kaunsa navigation menu hai aur kahan par image render karni hai.

HTML ke 4 sabse bade fayde hain:

  1. Structural Hierarchy: Ye webpage ka ek organized parent-child tree structure banata hai jise DOM (Document Object Model) kehte hain.
  2. Universal Accessibility: Screen readers (jo visually impaired ya blind users use karte hain) HTML tags ko read karke page navigate karwate hain.
  3. Search Engine Optimization (SEO): Google ya Bing ke crawlers HTML semantics se hi samajhte hain ki aapki website par kya content likha hai aur use search results mein kahan rank karna hai.
  4. Separation of Concerns: HTML ka kaam hai Content & Meaning, CSS ka kaam hai Styling & Beauty, aur JavaScript ka kaam hai Interactivity & Logic.

3. Simple Explanation (Real-Life Analogy)

Maan lijiye aap ek naya ghar bana rahe hain:

  • HTML ghar ki concrete foundation, eent ki deewarein aur pillars hain: Ye decide karta hai ki main door kahan hoga, bedrooms kahan honge aur khidkiyan kahan lagengi. Bina eenton aur cement ke ghar ka koi existence hi nahi hai.
  • CSS ghar ka paint, tiles, lighting aur interior decoration hai: Ye ghar ko sundar banata hai, color combination set karta hai aur rooms ka look decide karta hai.
  • JavaScript ghar ki electrical wiring, smart automation aur plumbing hai: Ye ghar ko functional banata hai — jaise remote dabane par automatic gate khulna, ya switch on karne par fan chalna.

Aap bare concrete deewaron wale ghar mein reh sakte hain (raw HTML), lekin bina physical deewaron ke aap paint ya smart switch nahi laga sakte.


4. Technical Explanation & Browser Rendering Pipeline

Jab aap browser mein URL type karte hain (jaise https://example.com) aur Enter press karte hain, to ye process hoti hai:

[ DNS Lookup ] ──► [ TCP Handshake & TLS ] ──► [ HTTP GET Request ]


                                                [ HTML Data Stream ]

Jab browser engine (jaise Chromium ka Blink ya WebKit) ko HTML ke bytes milte hain, to Critical Rendering Path execute hota hai:

Raw Bytes (e.g. 3C 68 74 6D 6C...)


Character Stream (UTF-8 Decoding)


Tokenization (<html>, <head>, <body>, <p> start/end tokens banana)


Nodes (Memory mein C++ objects create hona)


DOM Tree Construction ──────────┐

CSSOM Tree Construction ────────┼──► [ Render Tree ] ──► [ Layout (Reflow) ] ──► [ Painting ] ──► [ Compositing ]

Important Steps:

  1. Tokenization: Browser text ko read karke start tags, end tags aur attribute tokens banata hai.
  2. DOM Tree: Tokens ko memory ke andar tree structure mein connect kiya jata hai.
  3. Render Tree: DOM aur CSSOM aapas mein combine hote hain, jisme sirf screen par dikhne wale elements rehte hain (display: none wale filter ho jate hain).
  4. Layout (Reflow): Har element ka exact pixel size aur coordinate calculate kiya jata hai.
  5. Paint: Browser screen par pixels draw karta hai.

5. Syntax & Anatomy (HTML Element Ka Structure)

Ek complete HTML element mein opening tag, optional attributes, inner content aur closing tag hota hai:

┌──────────────────────────────────────────────────────────────┐
│                         HTML ELEMENT                         │
├────────────────────────────────┬───────────────┬─────────────┤
│           START TAG            │    CONTENT    │   END TAG   │
├─────────┬──────────────────────┤               ├─────────────┤
│ <button │ class="primary-btn"> │ Click Here    │ </button>   │
└─────────┴──────────────────────┴───────────────┴─────────────┘
  ▲         ▲             ▲
  │         │             └─ Attribute Value (quotes ke andar)
  │         └─ Attribute Name
  └─ Tag Name

Elements Ki Categories:

  • Container Elements (Paired Tags): Jinka opening tag aur closing tag dono hota hai aur beech mein content rehta hai (jaise <p>...</p>, <div>...</div>, <button>...</button>).
  • Void Elements (Self-closing): Jinme koi closing tag ya child content nahi hota (jaise <img>, <input>, <br>, <hr>, <meta>). HTML5 mein <img src="..."> likhna perfectly valid hai.
  • Block-level Elements: By default nayi line se shuru hote hain aur parent container ki poori 100% width cover karte hain (jaise <div>, <h1>-<h6>, <p>, <ul>, <section>).
  • Inline Elements: Line ke beech mein hi flow karte hain aur sirf utni hi width lete hain jitna unke content ki requirement hoti hai (jaise <span>, <a>, <strong>, <em>, <code>).

6. Basic Example: Standard HTML5 Skeleton

Production mein har ek HTML page is standard skeleton se start hona chahiye:

html
<!DOCTYPE html>
<html lang="hi">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Mera Web Development Portfolio</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <header>
    <nav>
      <a href="#about">About</a>
      <a href="#projects">Projects</a>
      <a href="#contact">Contact</a>
    </nav>
  </header>

  <main>
    <h1>Namaste! Main Ek Frontend Developer Hoon</h1>
    <p>Main high-performance aur accessible modern websites banata hoon.</p>
  </main>

  <footer>
    <p>&copy; 2026 Web Design Mastery. All rights reserved.</p>
  </footer>
</body>
</html>

7. Step-by-Step Explanation (Har Line Ka Matlab)

  1. <!DOCTYPE html>:
    • Matlab: Browser ko batata hai ki ye modern HTML5 Standards Mode mein render karna hai.
    • Kyun zaroori hai: Agar ye nahi likhenge to browser Quirks Mode mein chala jayega (1998 ke purane bugs emulate karega) jisse CSS layout kharab ho jayega.
  2. <html lang="hi"> ya <html lang="en">:
    • Matlab: Poore webpage ka root element hai. lang attribute screen readers ko batata hai ki page ki primary language kya hai taki voice engine sahi pronunciation use kare.
  3. <head>:
    • Matlab: Isme webpage ki metadata hoti hai jo screen par direct dikhti nahi hai, lekin browser aur search engines ke liye zaroori hoti hai.
  4. <meta charset="UTF-8">:
    • Matlab: UTF-8 character encoding set karta hai jisse English, Hindi, emojis aur symbols bina kisi garbar ke render hote hain.
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">:
    • Matlab: Mobile responsiveness ke liye sabse important line. Ye mobile browser ko kehti hai ki webpage ka width mobile screen ke barabar rakho aur bina zoom-out kiye 1:1 scale par open karo.
  6. <title>:
    • Matlab: Browser tab ka naam aur Google search results ka main clickable title.
  7. <body>:
    • Matlab: Webpage ka visible hissa jisme headings, paragraphs, images, tables aur forms hote hain.

8. Visual / Mental Model: DOM Tree

Browser aapke HTML code ko padhkar memory ke andar aisa tree structure banata hai:

                           Document

                           <html>

               ┌──────────────┴──────────────┐
               │                             │
            <head>                        <body>
               │                             │
        ┌──────┴──────┐               ┌──────┴──────┐
        │             │               │             │
     <meta>        <title>        <header>        <main>
                      │               │             │
                   "Title"          <nav>          <h1>
                                      │             │
                                     <a>        "Namaste"

9. Core HTML Tags Ka Practical Use

A. Text aur Formatting Elements

Kabhi bhi sirf text ko bold karne ke liye random tag mat lagaiye; meaning ke hisab se tag choose karein:

  • <h1> se <h6>: Page ki heading hierarchy. Poore page par sirf ek <h1> hona chahiye jo page ke main topic ko represent kare.
  • <p>: Paragraph ke liye.
  • <strong>: Aisi information jo bohot zaroori ya critical hai. Screen readers isko zyada heavy voice mein bolte hain.
  • <em>: Spoken voice mein kisi word par zorr (emphasis) dene ke liye.
  • <code>, <pre>, <kbd>: Technical documentation aur code blocks ke liye.
html
<p>
  Dependencies install karne ke liye terminal mein <kbd>npm install</kbd> run karein.
  Dhyan rahe ki <strong>Node.js 20+</strong> pehle se installed hona chahiye.
</p>

Hyperlinks ek page se doosre page ko connect karte hain href attribute ke through:

html
<!-- External Website Link (Secure tarika) -->
<a href="https://developer.mozilla.org" target="_blank" rel="noopener noreferrer">
  MDN Web Docs Padhein
</a>

<!-- Same Website Ka Internal Page -->
<a href="/about.html">Humare Baare Mein</a>

<!-- Page Ke Kisi Section Par Jump Karna -->
<a href="#pricing">Pricing Table Dekhein</a>

<!-- Direct Email aur Call Links -->
<a href="mailto:support@example.com">Email Karein</a>
<a href="tel:+919876543210">Call Karein</a>

WARNING

Jab bhi aap target="_blank" use karein, tab sath mein rel="noopener noreferrer" lagana compulsory hai! Warna naya page purane page ko access karke security vulnerability (Reverse Tabnabbing) create kar sakta hai.

C. Images aur Figures (<img>, <figure>)

Images void element hoti hain jisme src aur alt zaroori attributes hain:

html
<figure>
  <img 
    src="/images/architecture.webp" 
    alt="System architecture diagram jisme client, server aur database dikhaye gaye hain" 
    width="800" 
    height="450"
    loading="lazy"
  >
  <figcaption>Figure 1: High-level cloud infrastructure architecture.</figcaption>
</figure>
  • Alt text ka rule: Agar image informative hai to uska matlab describe karein. Agar image sirf background design ke liye hai to alt="" khali chhod dein taki screen reader use skip kar sake.
  • Layout shift rokna: Image par hamesha width aur height number dein taki image load hone se pehle hi browser uski jagah reserve kar le aur page jhatka na khaye (CLS issue na ho).

D. Semantic Lists

  • <ul>: Unordered list (bullet points) jahan order matter nahi karta.
  • <ol>: Ordered list (numbers) jahan steps ya ranking ka order zaroori hai.
  • <dl>, <dt>, <dd>: Description list jahan definition ya key-value pairs dikhane hote hain.
html
<dl>
  <dt>Status Code 200</dt>
  <dd>Request successfully complete ho gayi hai.</dd>
  <dt>Status Code 404</dt>
  <dd>Resource server par nahi mili.</dd>
</dl>

E. Accessible Tables

Tables ka use sirf tabular data (jaise marksheets, pricing sheets, schedule) dikhane ke liye karein, page layout banane ke liye nahi:

html
<table>
  <caption>Team Salary Breakdown (Monthly)</caption>
  <thead>
    <tr>
      <th scope="col">Employee Name</th>
      <th scope="col">Department</th>
      <th scope="col">Salary (INR)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">Rahul Sharma</th>
      <td>Engineering</td>
      <td>₹1,20,000</td>
    </tr>
    <tr>
      <th scope="row">Priya Verma</th>
      <td>Design</td>
      <td>₹1,10,000</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <th scope="row">Total Payout</th>
      <td colspan="2"><strong>₹2,30,000</strong></td>
    </tr>
  </tfoot>
</table>

F. Interactive HTML Forms

User se data input lene ke liye forms ka use hota hai:

html
<form action="/api/register" method="POST">
  <fieldset>
    <legend>Student Registration</legend>

    <!-- Label ke sath Input ka connection 'for' aur 'id' se hota hai -->
    <div>
      <label for="student-name">Full Name *</label>
      <input type="text" id="student-name" name="name" required placeholder="Aapka naam">
    </div>

    <div>
      <label for="student-email">Email Address *</label>
      <input type="email" id="student-email" name="email" required placeholder="naam@example.com">
    </div>

    <div>
      <label for="course">Course Select Karein</label>
      <select id="course" name="course">
        <option value="frontend">Frontend Web Development</option>
        <option value="fullstack">Full-Stack JavaScript</option>
      </select>
    </div>

    <button type="submit">Submit Form</button>
  </fieldset>
</form>

10. Common Mistakes (Jo Naye Developers Karte Hain)

  1. Input ke sath <label> na lagana:
    • Galti: <input type="text" placeholder="Name">
    • Solution: Label lagayein jisme for="input-ki-id" ho. Placeholder screen reader ke liye label ka replacement nahi hota.
  2. Heading levels skip karna:
    • Galti: <h1> ke turant baad <h4> likh dena kyunki text chhota dikhana tha.
    • Solution: Heading ka order h1h2h3 hona chahiye. Chhota dikhane ke liye CSS use karein, galat HTML tag nahi.
  3. Har jagah <div> use karna ("Div Soup"):
    • Galti: <div class="btn">Click</div>
    • Solution: Asli <button> tag use karein jisme keyboard accessibility (Tab + Enter key) by default working hoti hai.
  4. Link aur Button mein confuse hona:
    • Naye URL par jane ke liye <a> use karein.
    • Page par koi action perform karne ya modal open karne ke liye <button> use karein.

11. Best Practices (Professional Developers Ke Rules)

  • Hamesha <meta charset="UTF-8"> ko <head> ke top par rakhein.
  • Page par hamesha sirf ek hi <h1> use karein.
  • Images par loading="lazy" use karein taki unnecessary data waste na ho.
  • Native semantic tags (<nav>, <main>, <article>, <header>, <footer>) ko preference dein.

12. Accessibility, Performance & Security Notes

  • Accessibility: Screen reader users landmarks (<header>, <nav>, <main>, <footer>) ke sahare pure page ko fast navigate karte hain.
  • Performance: Images ka explicit width aur height dene se Cumulative Layout Shift (CLS) 0 ho jata hai.
  • Security: User ke inputs ko bina sanitize kiye direct HTML mein display na karein, warna Cross-Site Scripting (XSS) attack ho sakta hai.

13. Practice Questions

  1. <main> aur <section> tags mein kya farq hota hai?
  2. <!DOCTYPE html> na likhne par browser par kya asar padta hai?
  3. Block-level element aur Inline element mein 3 main differences batayein.
  4. Label tag ka for attribute input tag ke kis attribute se match hona chahiye?
  5. target="_blank" lagate waqt rel="noopener noreferrer" lagana kyun zaroori hai?

14. Mini Challenge (Khushi Se Try Karein)

Ek simple "Contact Card" bana kar dekhein jisme:

  1. Ek <header> ho jisme <h1> title ho.
  2. Ek <figure> aur <img> ho jisme profile photo ho.
  3. Ek form ho jisme Name, Email aur Message ka <textarea> ho aur sabhi fields par labels lage hon.
  4. Ek submit <button> ho.

15. Interview Questions & Answers

Q1: Agar <!DOCTYPE html> na likhein to kya hoga?

Answer: Agar DOCTYPE missing ho to browser Quirks Mode mein chala jata hai. Quirks mode mein browser 1990 ke puraane Internet Explorer 5 ke buggy behavior ko emulate karta hai taki puraani websites break na hon. Isse modern CSS layout, padding calculations aur box-sizing fail ho jati hain. Isliye modern HTML5 mein <!DOCTYPE html> likhna standard rule hai.

Q2: <b> aur <strong> mein kya farq hai?

Answer: <b> sirf text ko visually bold karta hai, iska koi semantic meaning nahi hota. Jabki <strong> browser aur screen reader ko batata hai ki ye text bohot zyada important ya urgent hai. Screen reader <strong> aane par apni voice tone change karta hai.


16. Quick Revision (Yaad Rakhne Layak Points)

  • HTML structure aur meaning banata hai, design nahi.
  • Skeleton essentials: <!DOCTYPE html>, <html lang="hi">, <head>, <meta charset="UTF-8">, <meta name="viewport">, <title>, <body>.
  • Ek page par ek hi <h1> hona chahiye.
  • Images par descriptive alt attribute aur explicit dimensions zaroor dein.
  • Action ke liye <button> aur navigation ke liye <a> use karein.

17. Next Topic (Agla Kadam)

Aapka agla step hai Module 02 — Advanced Semantic HTML & Accessibility, jahan hum complex semantic architecture, SEO metadata, native <dialog> modals, responsive <picture> aur WCAG/ARIA guidelines ko detail mein samjhenge.

G-TEC Jain Keerti Education — Global Leader in IT Education