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
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>.
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
Learning Outcomes โ Bloom's Taxonomy
| Bloom's Level | Learning Outcome |
|---|---|
| L1 โ Remember | Recall the purpose and syntax of all HTML5 semantic elements (header, footer, main, section, article, nav, aside) |
| L2 โ Understand | Explain WHY semantic HTML improves SEO, accessibility, and maintainability over div-based layouts |
| L3 โ Apply | Build a complete, valid HTML5 page with correct document structure, metadata, and semantic markup |
| L4 โ Analyze | Analyze a poorly structured HTML page and identify semantic, SEO, and accessibility violations |
| L5 โ Evaluate | Evaluate competing HTML structures for a real-world page (e.g., blog vs e-commerce) and justify which semantic elements to use |
| L6 โ Create | Design and build a complete multi-section webpage for an Indian startup using all HTML5 semantic elements |
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.
<div class="header">
<div class="nav">...</div>
</div>
<div class="content">
<div class="article">...</div>
<div class="sidebar">...</div>
</div>
<div class="footer">...</div><header>
<nav>...</nav>
</header>
<main>
<article>...</article>
<aside>...</aside>
</main>
<footer>...</footer>The 7 Core Semantic Elements
| Element | Purpose | Real-World Example |
|---|---|---|
<header> | Top section โ logo, navigation, branding | Swiggy's top bar with logo + search + cart |
<nav> | Navigation links | Flipkart'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 content | One blog post on Medium, one product card |
<aside> | Tangentially related content | "Related Products" sidebar on Amazon |
<footer> | Bottom section โ copyright, links, contact | Every 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>© 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
| Tag | Purpose | Visual | When to Use |
|---|---|---|---|
<strong> | Strong importance (semantic) | Bold | Important warnings, key terms |
<em> | Emphasis (semantic) | Italic | Stress emphasis in a sentence |
<mark> | Highlighted text | Highlighted | Search results, key phrases |
<small> | Fine print | Small text | Legal disclaimers, copyright |
<abbr> | Abbreviation with tooltip | Hover for full form | <abbr title="HyperText">HTML</abbr> |
<cite> | Citation of a work | Italic | Book titles, article names |
<dfn> | Term being defined | Definition | First use of a technical term |
<blockquote> | Block quotation | Indented block | Quoting 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 Elements | Inline Elements |
|---|---|
| Start on a new line | Stay in the same line |
| Take full available width | Take only the content's width |
<div>, <p>, <h1-h6>, <section>, <article>, <header>, <ul>, <ol> | <span>, <a>, <strong>, <em>, <mark>, <code>, <img> |
| Can contain block + inline | Can 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
- Online:
https://validator.w3.orgโ paste your code or URL - VS Code: Install "HTMLHint" extension โ real-time validation
- 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 โโโ -->
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>© 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."
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.
MCQ Assessment Bank โ 15 Questions (Bloom's Taxonomy)
Level 1 โ Remember โญ
Which declaration tells the browser to render the page in HTML5 standards mode?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"><!DOCTYPE html><html version="5"><meta http-equiv="X-UA-Compatible" content="html5">
๐
<!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
Which HTML5 element should contain the primary content of a page?
<div id="content"><section><main><body>
๐
<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
The <abbr> element is used to:
- Create a hyperlink
- Define an abbreviation with a tooltip showing the full form
- Make text bold
- Create a navigation menu
๐
<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
Level 2 โ Understand โญโญ
Why are semantic HTML elements preferred over generic <div> elements?
- They make the page load faster
- They provide meaning to browsers, screen readers, and search engines
- They automatically style the content
- They are required by JavaScript frameworks
๐ 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
What is the difference between <strong> and <b>?
- No difference โ they both make text bold
<strong>carries semantic importance;<b>is only visual<b>is HTML5;<strong>is deprecated<strong>is only for headings
๐
<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
Why should the lang attribute be set on the <html> tag?
- It changes the page's color scheme
- It helps search engines and screen readers determine the page's language
- It is required for JavaScript to work
- It prevents Cross-Site Scripting attacks
๐
<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
Level 3 โ Apply โญโญ
Which code correctly structures a blog post with semantic HTML?
<div class="post"><div class="title">...</div></div><article><h2>Title</h2><p>Content</p></article><section><p>Title</p><p>Content</p></section><main><span>Title</span><span>Content</span></main>
๐
<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
A student writes: <span><div>Content</div></span>. What will happen?
- It works perfectly โ HTML is flexible
- The browser auto-corrects it silently, but it produces invalid HTML
- It causes a JavaScript error
- The page won't load at all
๐ 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
Which meta tag makes a web page responsive on mobile devices?
<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="mobile" content="true"><meta http-equiv="responsive" content="yes">
๐ 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
Level 4 โ Analyze โญโญโญ
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?
- No impact โ multiple h1s are fine in HTML5
- Google may be confused about the page's primary topic, diluting SEO ranking
- The page won't render
- Only the last h1 is indexed by Google
๐ 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
A page loads slowly on mobile despite small file size. The developer forgot which meta tag?
<meta charset><meta name="description"><meta name="viewport"><meta property="og:title">
๐ 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
Level 5 โ Evaluate โญโญโญ
A teammate uses <div class="navigation"> instead of <nav>. In a code review, what feedback would you give?
- "It works, no need to change."
- "Use
<nav>because it provides accessibility benefits, SEO value, and follows HTML5 standards โ reducing technical debt." - "Add an id attribute and it's equivalent."
- "Use
<menu>instead."
๐
<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
A startup's homepage uses only <div> and <span> for all layout. It passes visual QA. Should the team refactor to semantic HTML?
- No โ if it looks right, it IS right
- Yes โ semantic HTML improves SEO ranking, accessibility compliance (legal requirement), developer readability, and reduces long-term maintenance cost
- Only if the site needs Google ranking
- Only if blind users are expected
๐ 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
Level 6 โ Create โญโญโญ
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?
- All in one
<div>with classes <article>for the booking,<section>s for passenger/journey/fare,<dl>for key-value pairs,<strong>for amounts- A single
<table>for everything <p>tags with line breaks for all content
๐
<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
A client needs their Razorpay payment page link to show a custom preview card on WhatsApp. Which HTML elements do you add?
- Just a
<title>tag - Open Graph meta tags:
og:title,og:description,og:image, andog:url - A
<preview>tag in the body - A JavaScript widget that generates the preview
๐ 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
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
- ๐ "HTML5 semantic elements MDN" โ Mozilla Developer Network's complete guide
- ๐ "Open Graph protocol documentation" โ Master social media link previews
- ๐ "Google Lighthouse accessibility audit" โ Run your first automated accessibility check
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)