Internet Programming Laboratory

Unit 1: Fundamentals of HTML5

HTML5 Document Structure, Semantic Elements, Metadata & SEO, Text Formatting, Block vs Inline, Validation โ€” the bedrock of every web page on the internet.

๐Ÿข Industry-Aligned  |  ๐Ÿ“ 15 MCQs (Bloom's Taxonomy)  |  ๐Ÿ”ฌ 5 Lab Exercises  |  ๐Ÿ’ผ Interview Prep

Section 1

Why This Chapter Matters in 2025

Every single thing you interact with on the internet โ€” from the Zomato restaurant page to your IRCTC train ticket โ€” is built on HTML. It is not a programming language; it is the skeleton of the web. Without it, CSS has nothing to style, JavaScript has nothing to manipulate, and React/Angular have no DOM to render into. HTML5 is the foundation. Master it first, or everything else will crumble.

๐Ÿข Industry Connection โ€” Who Uses HTML5 in Production?

Zomato uses semantic HTML5 (<article>, <section>) for every restaurant listing. Google's crawler reads these tags to rank Zomato pages higher โ€” if they used <div> everywhere, their SEO would collapse.

Flipkart structures every product page with <main>, <header>, <footer>, and <nav>. Their accessibility audit requires screen readers to navigate the page โ€” impossible without semantic HTML.

Razorpay uses HTML5 metadata (<meta> tags) for Open Graph previews. When you share a Razorpay payment link on WhatsApp, the preview card (title, description, image) comes from their HTML5 <head>.

๐Ÿ‡ฎ๐Ÿ‡ณ Zomato๐Ÿ‡ฎ๐Ÿ‡ณ Flipkart๐Ÿ‡ฎ๐Ÿ‡ณ Razorpay๐Ÿ‡ฎ๐Ÿ‡ณ CRED

Prerequisite Checklist โœ…

  • โœ… A text editor installed (VS Code recommended โ€” free, industry standard)
  • โœ… A modern web browser (Chrome/Firefox/Edge โ€” for DevTools)
  • โœ… Basic computer literacy (file/folder operations)
  • โœ… No prior coding experience required โ€” we start from absolute zero
Section 2

Learning Outcomes โ€” Bloom's Taxonomy

Bloom's LevelLearning Outcome
L1 โ€” RememberRecall the purpose and syntax of all HTML5 semantic elements (header, footer, main, section, article, nav, aside)
L2 โ€” UnderstandExplain WHY semantic HTML improves SEO, accessibility, and maintainability over div-based layouts
L3 โ€” ApplyBuild a complete, valid HTML5 page with correct document structure, metadata, and semantic markup
L4 โ€” AnalyzeAnalyze a poorly structured HTML page and identify semantic, SEO, and accessibility violations
L5 โ€” EvaluateEvaluate competing HTML structures for a real-world page (e.g., blog vs e-commerce) and justify which semantic elements to use
L6 โ€” CreateDesign and build a complete multi-section webpage for an Indian startup using all HTML5 semantic elements
Section 3

Concept Explanations โ€” Theory, Earned

3.1 HTML5 Document Structure

What it is

Every HTML5 page starts with a document structure โ€” a skeleton that tells the browser: "This is an HTML5 page, here's the language, here's the metadata, and here's the content."

Why it exists

Without this structure, browsers guess how to render your page. In the early 2000s, this "quirks mode" caused pages to look different in IE vs Firefox. The HTML5 doctype eliminates ambiguity.

How it works
HTML5
<!-- ๐Ÿ“ FILE: index.html -->
<!-- ๐Ÿข INDUSTRY CONTEXT: Every website on Earth starts with this exact structure -->

<!DOCTYPE html>            <!-- INDUSTRY NOTE: Tells browser "use HTML5 standards mode" -->
<html lang="en">            <!-- INDUSTRY NOTE: lang attribute helps screen readers & Google -->
<head>
  <meta charset="UTF-8">                        <!-- Supports Hindi: เคนเคฟเค‚เคฆเฅ€, Tamil: เฎคเฎฎเฎฟเฎดเฏ -->
  <meta name="viewport" content="width=device-width, initial-scale=1.0">  <!-- Mobile responsive -->
  <title>My First HTML5 Page</title>        <!-- Shows in browser tab & Google results -->
</head>
<body>
  <h1>Hello, HTML5!</h1>
  <p>This is my first properly structured web page.</p>
</body>
</html>

Students skip <!DOCTYPE html> and wonder why their CSS behaves strangely. Without the doctype, browsers enter "quirks mode" โ€” a legacy rendering mode where box-sizing, margins, and fonts behave unpredictably. Every professional HTML file starts with this line. No exceptions.

Real-World Analogy

Think of the HTML document like an official letter. The <!DOCTYPE> is the letterhead (identifies the document type). The <head> is the envelope (metadata: who it's for, subject, stamps). The <body> is the actual letter content. You wouldn't mail a letter without an envelope โ€” don't write HTML without a <head>.

3.2 Semantic HTML5 Elements

What they are

Semantic elements are HTML tags that describe their meaning to both the browser and the developer. <nav> means "navigation," <article> means "independent content," <footer> means "footer."

Why they exist

Before HTML5, developers used <div class="header">, <div class="nav">, <div class="footer"> for everything. Browsers, screen readers, and Google had NO idea what each div meant. Semantic elements solve this.

โŒ Before โ€” Div Soup (Pre-HTML5)
<div class="header">
  <div class="nav">...</div>
</div>
<div class="content">
  <div class="article">...</div>
  <div class="sidebar">...</div>
</div>
<div class="footer">...</div>
โœ… After โ€” Semantic HTML5
<header>
  <nav>...</nav>
</header>
<main>
  <article>...</article>
  <aside>...</aside>
</main>
<footer>...</footer>
The 7 Core Semantic Elements
ElementPurposeReal-World Example
<header>Top section โ€” logo, navigation, brandingSwiggy's top bar with logo + search + cart
<nav>Navigation linksFlipkart's category menu (Electronics, Fashion...)
<main>Primary content (only ONE per page)Zomato's restaurant listing area
<section>Thematic grouping with a heading"Trending Restaurants" section on Zomato
<article>Self-contained, reusable contentOne blog post on Medium, one product card
<aside>Tangentially related content"Related Products" sidebar on Amazon
<footer>Bottom section โ€” copyright, links, contactEvery website's bottom area

Screen readers (JAWS, NVDA, VoiceOver) use semantic elements to create an automatic outline. A blind user pressing "Skip to main content" jumps to <main>. Without it, they must listen to the entire navigation โ€” every single time. Semantic HTML is not optional; it's a legal requirement under India's RPWD Act 2016 and Section 508 (USA).

Complete Semantic Page Example
HTML5
<!-- ๐Ÿ“ FILE: zomato-clone.html -->
<!-- ๐Ÿข INDUSTRY CONTEXT: This is how Zomato structures its restaurant pages -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="Best restaurants in Bangalore โ€” order food online">
  <title>FoodExpress โ€” Order Food Online in Bangalore</title>
</head>
<body>

  <header>
    <h1>๐Ÿ• FoodExpress</h1>
    <nav aria-label="Main navigation">
      <ul>
        <li><a href="#home">Home</a></li>
        <li><a href="#restaurants">Restaurants</a></li>
        <li><a href="#cart">Cart (0)</a></li>
      </ul>
    </nav>
  </header>

  <main>
    <section id="trending">
      <h2>๐Ÿ”ฅ Trending Restaurants</h2>

      <article>
        <h3>Meghana Foods</h3>
        <p>Biryani, North Indian โ€ข โญ 4.5 โ€ข โ‚น300 for two</p>
        <p>Koramangala, Bangalore โ€” <mark>30 min delivery</mark></p>
      </article>

      <article>
        <h3>Empire Restaurant</h3>
        <p>Biryani, Kebabs โ€ข โญ 4.3 โ€ข โ‚น400 for two</p>
        <p>Indiranagar, Bangalore โ€” <mark>25 min delivery</mark></p>
      </article>
    </section>

    <aside>
      <h2>๐ŸŽ‰ Today's Offers</h2>
      <p>Use code <strong>FIRST50</strong> for 50% off on your first order!</p>
    </aside>
  </main>

  <footer>
    <p>&copy; 2025 FoodExpress. Made with โค๏ธ in Bangalore.</p>
    <p><small>Terms & Conditions | Privacy Policy</small></p>
  </footer>

</body>
</html>

3.3 Metadata & SEO-Friendly Head Elements

What it is

The <head> section contains metadata โ€” information about the page that isn't displayed but is critical for browsers, search engines, and social media platforms.

Why it exists

When you share an IRCTC link on WhatsApp, the preview card (title, image, description) comes from <meta> tags. When Google ranks pages, it reads <title> and <meta name="description">. Without proper metadata, your page is invisible to the world.

HTML5
<head>
  <!-- Character encoding โ€” ALWAYS UTF-8 in 2025 -->
  <meta charset="UTF-8">

  <!-- Responsive viewport โ€” MANDATORY for mobile -->
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <!-- SEO: Title tag โ€” shows in Google results & browser tab -->
  <title>IRCTC Train Booking โ€” Book Tickets Online</title>

  <!-- SEO: Meta description โ€” the snippet under Google title -->
  <meta name="description" content="Book train tickets online on IRCTC. Check PNR status, train schedule, seat availability.">

  <!-- SEO: Keywords (less important now, but still used) -->
  <meta name="keywords" content="IRCTC, train booking, PNR status, Indian Railways">

  <!-- Open Graph: WhatsApp/Facebook/LinkedIn preview -->
  <meta property="og:title" content="IRCTC โ€” Book Train Tickets">
  <meta property="og:description" content="India's official train booking platform">
  <meta property="og:image" content="https://irctc.co.in/og-image.jpg">

  <!-- Favicon โ€” the small icon in browser tab -->
  <link rel="icon" href="favicon.ico" type="image/x-icon">

  <!-- External CSS -->
  <link rel="stylesheet" href="style.css">
</head>

Open Graph (OG) Tags โ€” A protocol created by Facebook that controls how your page appears when shared on social media. When someone shares your startup's link on LinkedIn, the title, description, and image shown in the preview card come from OG meta tags. Razorpay, CRED, and every Indian startup uses these.

3.4 Heading Hierarchy (h1 โ†’ h6)

What it is

HTML provides 6 levels of headings โ€” <h1> (most important) through <h6> (least). They define the outline of your page, like chapters and sub-sections in a book.

The Golden Rule

Only ONE <h1> per page. It's the page title. Then use h2 for major sections, h3 for sub-sections, and so on. Never skip levels (don't jump from h1 to h4).

HTML5 โ€” Correct Heading Hierarchy
<h1>Swiggy โ€” Food Delivery App</h1>              <!-- Page title (ONE per page) -->
  <h2>Popular Restaurants</h2>                   <!-- Section -->
    <h3>Meghana Foods</h3>                       <!-- Sub-section -->
    <h3>Empire Restaurant</h3>                   <!-- Another sub-section -->
  <h2>Today's Offers</h2>                       <!-- Another section -->
    <h3>Flat 50% Off on First Order</h3>

Students use <h1> because it's "big" and <h4> because it's "small." Headings are NOT for font sizing โ€” that's CSS's job. Using <h1> for a small sidebar title destroys your page's SEO outline. Google reads heading hierarchy to understand content structure.

3.5 Text Formatting Tags

TagPurposeVisualWhen to Use
<strong>Strong importance (semantic)BoldImportant warnings, key terms
<em>Emphasis (semantic)ItalicStress emphasis in a sentence
<mark>Highlighted textHighlightedSearch results, key phrases
<small>Fine printSmall textLegal disclaimers, copyright
<abbr>Abbreviation with tooltipHover for full form<abbr title="HyperText">HTML</abbr>
<cite>Citation of a workItalicBook titles, article names
<dfn>Term being definedDefinitionFirst use of a technical term
<blockquote>Block quotationIndented blockQuoting external sources
<q>Inline quotation"Quoted"Short quotes within text

<b> and <i> are presentation-only tags โ€” they make text bold/italic but carry no semantic meaning. Screen readers cannot distinguish <b> from regular text. Always use <strong> (importance) and <em> (emphasis) instead. Companies like TCS and Infosys flag <b>/<i> in code reviews.

3.6 Block vs Inline Elements

Real-World Analogy

Think of a page like a bookshelf. Block elements are like books placed horizontally โ€” each takes the entire shelf width and starts on a new shelf. Inline elements are like bookmarks inside a book โ€” they sit within the text flow without breaking onto a new line.

Block ElementsInline Elements
Start on a new lineStay in the same line
Take full available widthTake only the content's width
<div>, <p>, <h1-h6>, <section>, <article>, <header>, <ul>, <ol><span>, <a>, <strong>, <em>, <mark>, <code>, <img>
Can contain block + inlineCan only contain inline

Putting a <div> (block) inside a <span> (inline) is invalid HTML. Inline elements cannot contain block elements. This will cause unpredictable rendering. The W3C validator will flag this as an error.

3.7 HTML5 Validation

What it is

HTML validation checks if your code follows the W3C HTML5 specification. It catches missing closing tags, invalid nesting, deprecated attributes, and accessibility issues.

Why it matters

Invalid HTML renders inconsistently across browsers. TCS, Infosys, and Wipro include HTML validation in their code quality tools (SonarQube). Google's Lighthouse audit penalizes invalid HTML.

How to validate
  1. Online: https://validator.w3.org โ€” paste your code or URL
  2. VS Code: Install "HTMLHint" extension โ€” real-time validation
  3. Browser DevTools: Chrome โ†’ F12 โ†’ Console โ†’ HTML errors appear automatically

Make it a habit: Validate your HTML before every submission. In the industry, CI/CD pipelines at Flipkart and Razorpay run HTML validation automatically โ€” invalid HTML blocks deployment. Start building this muscle memory now.

HTML Comments
HTML5
<!-- This is an HTML comment -->
<!-- Comments are invisible to users but visible in source code -->
<!-- INDUSTRY NOTE: Use comments to mark sections for team collaboration -->

<!-- โ•โ•โ• HEADER SECTION START โ•โ•โ• -->
<header>...</header>
<!-- โ•โ•โ• HEADER SECTION END โ•โ•โ• -->
Section 4

Real-Life Industry Problems

๐Ÿข INDUSTRY PROBLEM #1 โ€” Build a Product Listing Page (Meesho-Style)

Scenario

A startup called "ShopDesi" is building India's next social commerce platform. They need a product listing page that Google can crawl effectively, screen readers can navigate, and mobile users can browse.

Requirements
  • Valid HTML5 document with complete metadata (title, description, OG tags)
  • Semantic structure: header with nav, main with product articles, aside with filters, footer
  • At least 4 product cards using <article> with product name, price, rating
  • Use <mark> for discount badges, <strong> for prices
  • Include <abbr> for abbreviations (GST, COD, EMI)
Complete Solution
HTML5
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="Shop affordable fashion, electronics & home decor on ShopDesi">
  <meta property="og:title" content="ShopDesi โ€” India's Social Commerce Platform">
  <title>ShopDesi โ€” Shop Affordable Fashion Online</title>
</head>
<body>
  <header>
    <h1>๐Ÿ›๏ธ ShopDesi</h1>
    <nav aria-label="Main navigation">
      <ul>
        <li><a href="#women">Women</a></li>
        <li><a href="#men">Men</a></li>
        <li><a href="#electronics">Electronics</a></li>
        <li><a href="#home">Home & Kitchen</a></li>
      </ul>
    </nav>
  </header>

  <main>
    <section id="women">
      <h2>๐Ÿ‘— Women's Fashion</h2>

      <article>
        <h3>Cotton Kurti Set</h3>
        <p>Price: <strong>โ‚น449</strong> <small><s>โ‚น999</s></small> <mark>55% OFF</mark></p>
        <p>โญโญโญโญ (2,340 ratings)</p>
        <p><small>Free delivery | <abbr title="Cash On Delivery">COD</abbr> available</small></p>
      </article>

      <article>
        <h3>Embroidered Saree</h3>
        <p>Price: <strong>โ‚น799</strong> <small><s>โ‚น1,599</s></small> <mark>50% OFF</mark></p>
        <p>โญโญโญโญโญ (5,120 ratings)</p>
        <p><small>Incl. <abbr title="Goods and Services Tax">GST</abbr> | <abbr title="Equated Monthly Installment">EMI</abbr> from โ‚น67/mo</small></p>
      </article>
    </section>
  </main>

  <aside>
    <h2>๐Ÿท๏ธ Filters</h2>
    <p><strong>Price Range:</strong> Under โ‚น500 | โ‚น500โ€“โ‚น1000 | Above โ‚น1000</p>
    <p><strong>Rating:</strong> 4โ˜… & above</p>
  </aside>

  <footer>
    <p>&copy; 2025 ShopDesi. All rights reserved.</p>
    <p><small>Contact: support@shopdesi.in | Toll-free: 1800-123-4567</small></p>
  </footer>
</body>
</html>

What This Teaches: Semantic HTML layout, SEO metadata, accessibility patterns. Interview Angle: "Flipkart and Meesho ask freshers to build exactly this โ€” a product page with proper HTML structure."

๐Ÿข INDUSTRY PROBLEM #2 โ€” College Department Page (AICTE-Compliant)

Scenario

Your college's CSE department needs a single-page website for NAAC accreditation. It must pass W3C validation and be readable by screen readers.

Requirements
  • Header with department name, nav with 5 sections
  • About section (<section>), Faculty section with 3+ faculty articles, Courses, Contact
  • Proper heading hierarchy (h1 โ†’ h2 โ†’ h3)
  • Footer with AICTE approval number
  • Use <blockquote> for a motivational quote from HOD

Student Task: Build the complete page. Validate at validator.w3.org. Zero errors required.

๐Ÿข INDUSTRY PROBLEM #3 โ€” News Article Page (The Hindu / NDTV Style)

Scenario

Build a news article page for a digital media startup. Google must understand the article's headline, author, date, and content โ€” all through semantic HTML.

Requirements
  • Use <article> as the main container for the news story
  • Include <time datetime="2025-01-15"> for the publication date
  • Use <cite> for quoting sources, <blockquote> for expert quotes
  • Header with site branding, nav with categories (Politics, Sports, Tech)
  • Aside with "Related Articles" and "Trending Now"

Interview Angle: "Content platforms like DailyHunt and Inshorts structure articles exactly like this for Google Discover ranking."

Section 5

Lab Exercises

๐ŸŸข Beginner Exercise 1: My First HTML5 Page

Estimated Time: 20 minutes

Create a valid HTML5 page about yourself. Include: your name as h1, a paragraph about your hobbies, your college name using <strong>, and a motivational quote using <blockquote>. Validate at validator.w3.org โ€” zero errors.

Hints: (1) Start with . (2) Don't forget lang="en" on html tag. (3) Include viewport meta for mobile.

Extension: Add Open Graph meta tags so when shared on WhatsApp, it shows a proper preview.

๐ŸŸข Beginner Exercise 2: Semantic Page Skeleton

Estimated Time: 30 minutes

Build a page skeleton for a food delivery app with: <header> (logo + nav with 4 links), <main> containing two <section>s (each with h2 heading and 2 <article>s), an <aside> for offers, and a <footer> with copyright.

Hints: (1) nav should contain ul > li > a. (2) Only ONE main per page. (3) Each section needs a heading.

๐ŸŸก Intermediate Exercise 3: Text Formatting Showcase

Estimated Time: 25 minutes

Create a page that uses ALL text formatting tags in a meaningful context. Write a short article about "UPI Payments in India" using: <strong>, <em>, <mark>, <small>, <abbr> (for UPI, NPCI, RBI), <cite>, <blockquote> (quote from RBI Governor), and <dfn> (define "Unified Payments Interface").

Extension: Add a "Timeline of UPI" section with proper heading hierarchy.

๐Ÿ”ด Advanced Exercise 4: Audit & Fix Broken HTML

Estimated Time: 35 minutes

Given this intentionally broken HTML, find and fix ALL errors:

Broken HTML โ€” Find 8 Errors
<html>
<head><title>My Page</head>
<body>
<h1>Welcome</h3>
<div><span><div>Nested wrong</div></span></div>
<p>Hello <strong>World</p></strong>
<h1>Another main heading</h1>
<h4>Skipped from h1 to h4</h4>
<img src="photo.jpg">

Hints: (1) Count mismatched tags. (2) Check nesting rules. (3) img needs alt attribute.

โšซ Industry-Level Exercise 5: Startup Landing Page

Estimated Time: 45 minutes

Build a complete, validated HTML5 landing page for a fictional Indian startup called "QuickKisan" โ€” a platform connecting farmers directly to consumers. Include: hero section, features (3 articles), testimonials (blockquotes), team section (3 members with dfn for titles), and footer with contact. Must pass W3C validation with zero errors. Include all meta tags, OG tags, and aria-labels.

Extension: Add structured data (application/ld+json) for Google rich results.

Section 6

MCQ Assessment Bank โ€” 15 Questions (Bloom's Taxonomy)

Level 1 โ€” Remember โญ

Q1

Which declaration tells the browser to render the page in HTML5 standards mode?

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
  2. <!DOCTYPE html>
  3. <html version="5">
  4. <meta http-equiv="X-UA-Compatible" content="html5">
โœ… B
๐Ÿ“– <!DOCTYPE html> is the HTML5 doctype โ€” simple, clean, and universally supported. The long doctype in option A is HTML 4.01. Options C and D are fabricated.
๐Ÿข Tested in: TCS NQT, Wipro NLTH
L1 Remember
Q2

Which HTML5 element should contain the primary content of a page?

  1. <div id="content">
  2. <section>
  3. <main>
  4. <body>
โœ… C
๐Ÿ“– <main> is specifically designed for the primary content. Only ONE per page. <div> has no semantic meaning. <section> is for thematic grouping within main. <body> is the entire page.
๐Ÿข Tested in: Infosys Hackathon
L1 Remember
Q3

The <abbr> element is used to:

  1. Create a hyperlink
  2. Define an abbreviation with a tooltip showing the full form
  3. Make text bold
  4. Create a navigation menu
โœ… B
๐Ÿ“– <abbr title="Goods and Services Tax">GST</abbr> โ€” on hover, users see the full form. Screen readers also announce the full form. Options A, C, D describe other elements.
๐Ÿข Tested in: AMCAT
L1 Remember

Level 2 โ€” Understand โญโญ

Q4

Why are semantic HTML elements preferred over generic <div> elements?

  1. They make the page load faster
  2. They provide meaning to browsers, screen readers, and search engines
  3. They automatically style the content
  4. They are required by JavaScript frameworks
โœ… B
๐Ÿ“– Semantic elements convey meaning. Google uses <article> to understand blog posts; screen readers use <nav> to find navigation. Divs are invisible to these tools. (A) Page speed is unaffected. (C) They have minimal default styling. (D) Frameworks work with any element.
๐Ÿข Tested in: TCS NQT, Cognizant GenC
L2 Understand
Q5

What is the difference between <strong> and <b>?

  1. No difference โ€” they both make text bold
  2. <strong> carries semantic importance; <b> is only visual
  3. <b> is HTML5; <strong> is deprecated
  4. <strong> is only for headings
โœ… B
๐Ÿ“– <strong> tells screen readers "this is important" โ€” they change tone/emphasis. <b> is purely visual. (A) Visually same but semantically different. (C) <strong> is the modern standard. (D) Works in any context.
๐Ÿข Tested in: Wipro NLTH
L2 Understand
Q6

Why should the lang attribute be set on the <html> tag?

  1. It changes the page's color scheme
  2. It helps search engines and screen readers determine the page's language
  3. It is required for JavaScript to work
  4. It prevents Cross-Site Scripting attacks
โœ… B
๐Ÿ“– <html lang="en"> tells Google "this page is in English," and screen readers use the correct pronunciation engine. Without it, a Hindi page might be read with English pronunciation. (A)(C)(D) are incorrect.
๐Ÿข Tested in: Google Lighthouse Audit
L2 Understand

Level 3 โ€” Apply โญโญ

Q7

Which code correctly structures a blog post with semantic HTML?

  1. <div class="post"><div class="title">...</div></div>
  2. <article><h2>Title</h2><p>Content</p></article>
  3. <section><p>Title</p><p>Content</p></section>
  4. <main><span>Title</span><span>Content</span></main>
โœ… B
๐Ÿ“– <article> is for self-contained, reusable content (blog posts, product cards). <h2> provides the heading. (A) Divs have no semantic meaning. (C) Section needs a heading and isn't self-contained. (D) Span is inline โ€” can't contain block content.
๐Ÿข Tested in: Infosys InfyTQ
L3 Apply
Q8

A student writes: <span><div>Content</div></span>. What will happen?

  1. It works perfectly โ€” HTML is flexible
  2. The browser auto-corrects it silently, but it produces invalid HTML
  3. It causes a JavaScript error
  4. The page won't load at all
โœ… B
๐Ÿ“– Inline elements (<span>) cannot contain block elements (<div>). Browsers may auto-correct (quirks mode), but W3C validator flags this as invalid. Code may render unpredictably. (A) It violates HTML spec. (C)(D) Pages load but with issues.
๐Ÿข Tested in: SonarQube Code Quality Scan
L3 Apply
Q9

Which meta tag makes a web page responsive on mobile devices?

  1. <meta charset="UTF-8">
  2. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  3. <meta name="mobile" content="true">
  4. <meta http-equiv="responsive" content="yes">
โœ… B
๐Ÿ“– The viewport meta tag tells mobile browsers to match the page width to the device width. Without it, mobile browsers render at desktop width (typically 980px) and shrink. (A) Character encoding. (C)(D) Fabricated tags.
๐Ÿข Tested in: Every mobile-first project
L3 Apply

Level 4 โ€” Analyze โญโญโญ

Q10

A developer uses three <h1> tags on a single page: one for the site title, one for the article title, and one for a sidebar heading. What is the SEO impact?

  1. No impact โ€” multiple h1s are fine in HTML5
  2. Google may be confused about the page's primary topic, diluting SEO ranking
  3. The page won't render
  4. Only the last h1 is indexed by Google
โœ… B
๐Ÿ“– While HTML5 technically allows multiple h1s (in sectioning contexts), SEO best practice is ONE h1 per page. Multiple h1s dilute the page's focus keyword signal. Google's John Mueller has confirmed this. (A) Technically valid but bad practice. (C)(D) Incorrect.
๐Ÿข Tested in: Google SEO Certification
L4 Analyze
Q11

A page loads slowly on mobile despite small file size. The developer forgot which meta tag?

  1. <meta charset>
  2. <meta name="description">
  3. <meta name="viewport">
  4. <meta property="og:title">
โœ… C
๐Ÿ“– Without the viewport meta, mobile browsers render at desktop width (980px) and then scale down โ€” causing text to appear tiny and requiring zooming. The page isn't "slow" โ€” it's rendering at the wrong scale, making it feel broken. (A)(B)(D) Don't affect rendering.
๐Ÿข Tested in: Google Lighthouse Mobile Audit
L4 Analyze

Level 5 โ€” Evaluate โญโญโญ

Q12

A teammate uses <div class="navigation"> instead of <nav>. In a code review, what feedback would you give?

  1. "It works, no need to change."
  2. "Use <nav> because it provides accessibility benefits, SEO value, and follows HTML5 standards โ€” reducing technical debt."
  3. "Add an id attribute and it's equivalent."
  4. "Use <menu> instead."
โœ… B
๐Ÿ“– <nav> provides: (1) Screen reader landmark navigation, (2) SEO signals, (3) Code readability. Divs with classes are unsemantic โ€” they work visually but miss all semantic benefits. (A) Ignores best practices. (C) id doesn't add semantics. (D) <menu> is for context menus, not navigation.
๐Ÿข Code review scenario at Flipkart/Swiggy
L5 Evaluate
Q13

A startup's homepage uses only <div> and <span> for all layout. It passes visual QA. Should the team refactor to semantic HTML?

  1. No โ€” if it looks right, it IS right
  2. Yes โ€” semantic HTML improves SEO ranking, accessibility compliance (legal requirement), developer readability, and reduces long-term maintenance cost
  3. Only if the site needs Google ranking
  4. Only if blind users are expected
โœ… B
๐Ÿ“– Semantic HTML is a quality attribute โ€” like code formatting. (A) Visual correctness โ‰  semantic correctness. (C)(D) Accessibility is a legal requirement under RPWD Act 2016, not optional. Refactoring pays off in SEO, maintenance, and compliance.
๐Ÿข Architecture discussion at any product company
L5 Evaluate

Level 6 โ€” Create โญโญโญ

Q14

You're designing the HTML structure for an IRCTC-style train booking confirmation page. Which element combination best structures: booking ID, passenger details, journey details, and fare breakdown?

  1. All in one <div> with classes
  2. <article> for the booking, <section>s for passenger/journey/fare, <dl> for key-value pairs, <strong> for amounts
  3. A single <table> for everything
  4. <p> tags with line breaks for all content
โœ… B
๐Ÿ“– <article> wraps the self-contained booking. <section>s group related content. <dl> (definition list) is perfect for key-value pairs (PNR: 4321, Train: Rajdhani). <strong> highlights fare amounts. (A) No semantics. (C) Not tabular data. (D) No structure.
๐Ÿข Design question at any product company
L6 Create
Q15

A client needs their Razorpay payment page link to show a custom preview card on WhatsApp. Which HTML elements do you add?

  1. Just a <title> tag
  2. Open Graph meta tags: og:title, og:description, og:image, and og:url
  3. A <preview> tag in the body
  4. A JavaScript widget that generates the preview
โœ… B
๐Ÿ“– WhatsApp, LinkedIn, and Twitter read Open Graph meta tags from the <head> to generate link preview cards. All four OG tags (title, description, image, url) are needed for a complete preview. (A) Title alone gives minimal preview. (C) No such tag. (D) Social platforms don't execute JS for previews.
๐Ÿข Tested in: Every startup's SEO/marketing setup
L6 Create
Section 7

Chapter Summary

Concept Mind Map

Mind Map
                          HTML5 FUNDAMENTALS
                               โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     Document         Semantic      Metadata         Text
     Structure        Elements      & SEO          Formatting
     โ”‚                โ”‚             โ”‚                โ”‚
     โ”œโ”€ DOCTYPE       โ”œโ”€ header     โ”œโ”€ charset       โ”œโ”€ strong (importance)
     โ”œโ”€ html(lang)    โ”œโ”€ nav        โ”œโ”€ viewport      โ”œโ”€ em (emphasis)
     โ”œโ”€ head          โ”œโ”€ main       โ”œโ”€ title         โ”œโ”€ mark (highlight)
     โ””โ”€ body          โ”œโ”€ section    โ”œโ”€ description   โ”œโ”€ small (fine print)
                      โ”œโ”€ article    โ”œโ”€ OG tags       โ”œโ”€ abbr (abbreviation)
                      โ”œโ”€ aside      โ””โ”€ favicon       โ”œโ”€ cite (citation)
                      โ””โ”€ footer                      โ”œโ”€ dfn (definition)
                                                     โ””โ”€ blockquote/q

Key Takeaways for Industry

  • HTML5 is not just tags โ€” it's a communication protocol between your code, browsers, screen readers, and search engines. Every semantic element is a message.
  • One h1 per page, always. Your heading hierarchy is your page's outline. Google and screen readers depend on it.
  • Metadata is your page's business card. Without proper title, description, and OG tags, your page is invisible on Google and produces ugly link previews on WhatsApp.
  • Validate, validate, validate. Use validator.w3.org before every submission. In the industry, invalid HTML blocks CI/CD deployment.
  • Accessibility is a legal requirement, not a nice-to-have. RPWD Act 2016 (India) and Section 508 (USA) mandate accessible websites. Semantic HTML is step one.

Quick Reference Card โ€” HTML5 Essentials

DOCUMENT          SEMANTIC ELEMENTS       TEXT FORMATTING
<!DOCTYPE html>   <header>  <footer>     <strong> โ†’ importance
<html lang="en">  <nav>     <main>       <em>     โ†’ emphasis
<head>  <body>    <section> <article>    <mark>   โ†’ highlight
                   <aside>               <small>  โ†’ fine print
METADATA                                 <abbr>   โ†’ abbreviation
<meta charset>    BLOCK vs INLINE        <cite>   โ†’ citation
<meta viewport>   Block: div,p,h1-h6     <dfn>    โ†’ definition
<title>            section,article       <blockquote> โ†’ long quote
<meta description> Inline: span,a,       <q>      โ†’ inline quote
<meta og:*>        strong,em,mark,code

"What to Google Next" โ€” Self-Study Resources

  1. ๐Ÿ” "HTML5 semantic elements MDN" โ€” Mozilla Developer Network's complete guide
  2. ๐Ÿ” "Open Graph protocol documentation" โ€” Master social media link previews
  3. ๐Ÿ” "Google Lighthouse accessibility audit" โ€” Run your first automated accessibility check
Section 8

Interview Preparation

10 Frequently Asked Interview Questions

1. What is the difference between HTML and HTML5?

HTML5 introduced semantic elements (header, nav, main, article), native audio/video support, canvas, local storage, and new form input types. It replaced the long DOCTYPE with <!DOCTYPE html> and mandated UTF-8 character encoding. Key point: HTML5 is not a new language โ€” it's the latest evolution of the same HTML standard.

2. What are semantic elements? Name 5.

Semantic elements describe their content's meaning to browsers and screen readers. Five examples: <header>, <nav>, <main>, <article>, <footer>. They improve SEO, accessibility, and code maintainability.

3. Why is only one <main> element allowed per page?

<main> represents the page's primary, unique content (excluding headers, nav, sidebars). Multiple mains would confuse screen readers about what the "main" content is. The ARIA landmark role main is implicitly assigned to this element.

4. What is the purpose of the viewport meta tag?

It tells mobile browsers to set the page width equal to the device width and initial zoom to 100%. Without it, mobile browsers render at desktop width (~980px) and shrink everything down, making text unreadable.

5. Explain the difference between <section> and <article>.

<article> is for self-contained, independently distributable content (a blog post, a product card). <section> is for thematic grouping of related content that requires a heading. Articles can contain sections, and sections can contain articles.

6. What are Open Graph meta tags?

OG tags control how your page appears when shared on social media (WhatsApp, LinkedIn, Facebook). Key tags: og:title, og:description, og:image, og:url. Without them, shared links show generic previews.

7. What happens if you skip the <!DOCTYPE html> declaration?

The browser enters "quirks mode" โ€” a legacy rendering mode where CSS box model, margins, and fonts behave differently than the standard. This causes cross-browser inconsistencies. Always include the doctype.

8. Block vs inline elements โ€” give 3 examples of each.

Block: <div>, <p>, <h1> โ€” start on new line, take full width. Inline: <span>, <a>, <strong> โ€” stay in the text flow, take content width only. An inline element cannot contain a block element.

9. How do you validate an HTML page?

Use validator.w3.org (online), HTMLHint VS Code extension (real-time), or Google Lighthouse (Chrome DevTools). In production, CI/CD pipelines use tools like SonarQube for automated validation.

10. Why does accessibility matter in web development?

~15% of the world's population lives with some form of disability. Accessible websites are legally required (India's RPWD Act 2016, USA's Section 508). Semantic HTML, ARIA labels, and keyboard navigation are the first steps. Companies like Flipkart and Razorpay mandate WCAG 2.1 AA compliance.

GitHub Portfolio Tip ๐Ÿ’ผ

Build and push to GitHub: A fully semantic, W3C-validated landing page for a fictional Indian startup (food delivery, fintech, edtech). Include proper metadata, OG tags, accessibility features, and a README explaining your HTML structure choices. This is the #1 thing freshers lack in portfolios โ€” clean, semantic HTML.

Certification Path ๐ŸŽ“

  • โœ… freeCodeCamp โ€” Responsive Web Design (HTML section) โ€” Free certificate
  • โœ… The Odin Project โ€” Foundations: HTML (free, project-based)
  • โœ… Google โ€” Web Fundamentals (developers.google.com/web)
  • โœ… W3Schools โ€” HTML Certificate (paid but recognized)