HTML5 & Semantic Web Architecture Master Interview Bank
HTML5 semantic elements, DOM tree construction, forms & Constraint Validation API, dialog vs Popover API, Resource Hints, Web Storage, Web Components, and Web Workers.
Curriculum Roadmap & Learning Path
3 StagesPart 1: Basic & Foundational Concepts (Junior / Entry-Level)
12 QuestionsWhat is HTML5 and what is the role of `<!DOCTYPE html>`?
HTML5 is the standard markup language for structuring web pages • ``: An essential declaration placed on the very first line of an HTML document.
What are Semantic HTML5 elements and why are they critical?
Semantic elements clearly describe their meaning to both the browser and the developer (e.g., , , , , , , ) instead of generic unsemantic containers like and .: Accessibility (a11y): Screen readers use semantic landmarks to allow visually impaired users to jump directly to navigation () or primary.
What is the difference between `<article>` and `<section>`?
: Represents a complete, self-contained piece of content that could be distributed and syndicated independently (e.g., a blog post, news story • `: Represents a thematic grouping of content, typically with a heading.
What is the HTML DOM and how is it constructed from HTML tokens?
The Document Object Model (DOM) is an in-memory, tree-structured object representation of an HTML document that JavaScript can inspect and manipulate. #### The 5-Step Pipeline from Raw Bytes to DOM.
How do standard HTML forms work and what are the native form controls?
A ` collects user input and transmits it to a server endpoint via an HTTP method: action: The server URL endpoint to which data is submitted • method: The HTTP method (GET appends form data to the URL query string; POST transmits data in the HTTP request body) • Core Form Elements • `: Single-line input with diverse types.
What are the modern `<input>` types and native validation attributes?
HTML5 introduced specialized input types that provide native mobile keyboard layouts and browser validation: Types: email, tel (opens number pad on phones), url, number, date, color, file, range • Native Validation Attributes • required: Field must not be empty • minlength & maxlength: String length constraints.
What is the difference between `type="submit"`, `type="button"`, and `type="reset"`?
(Default behavior inside ): Submits the form data to the action URL when clicked or when the user presses Enter in an input field • : Does nothing by default • `: Resets all form fields back to their original default values.
How does media embedding work with `<picture>`, `<source>`, and `<img>`?
While displays a single image, the element enables art direction and responsive format selection.
What are the differences between `defer`, `async`, and standard `<script>` loading?
``` HTML Parsing: ====================[BLOCKED]=====================> Standard Script: [Download][Execute] HTML Parsing: ==================================================> Async Script: [Download] Execution: [Execute BLOCKS Parsing] HTML Parsing: ==================================================> (HTML Finishes) Defer Script...
What is the purpose of the `<meta name="viewport">` tag in responsive design?
By default, mobile browsers assume desktop websites and render pages inside an artificial 980px virtual viewport, zooming out until text is • width=device-width: Tells the browser to set the viewport width to the physical pixel width of the device screen.
What are HTML entities and why must user inputs be escaped?
In HTML, characters like ` are reserved for tag syntax.: If a user submits a comment containing alert('hacked') and you render it unescaped, the browser interprets it as executable code (Cross-Site • HTML Entities encode reserved characters into safe character entities • < • >.
What is the difference between `id`, `class`, and `name` attributes?
id: Unique identifier for an element • class: Non-unique identifier shared across multiple elements for CSS styling and DOM querying (document.querySelectorAll('.card')) • name: The key submitted in HTTP form payloads (?name=value).
Part 2: Core Architecture & Implementation (Mid-Level)
12 QuestionsWhat is the native HTML `<dialog>` element (`.showModal()` vs. `.show()`)?
Before HTML5 , building accessible modal dialogs required hundreds of lines of JavaScript to manage focus traps, overlay backdrops, and ESC key handling. The native handles all of this automatically.
What is the Popover API (`popover="auto|manual"`)?
Introduced natively in modern browsers (Baseline 2024), the Popover API creates tooltips, menus, and dropdowns without writing JavaScript event listeners.
What are Resource Hints (`preload`, `prefetch`, `preconnect`, `dns-prefetch`)?
Informs the browser's network stack about resources before the HTML parser discovers them: rel="preconnect": Initiates early DNS lookup, TCP handshake, and TLS negotiation to an external origin (e.g., Google Fonts or Cloudinary CDN).
Web Storage Comparison: `localStorage` vs. `sessionStorage` vs. `IndexedDB` vs. `Cookies`.
Storage API Capacity Scope & Lifecycle Server Access Use Cases.
What is the HTML5 Drag and Drop API?
Enables native dragging of elements and external files.
What are Custom Data Attributes (`data-*`)?
Allows storing extra custom metadata on standard HTML elements without violating specifications.
What is the `<template>` element?
The `` tag holds client-side HTML markup that is parsed but not rendered on page load.
What are Web Components and Custom Elements (`customElements.define`)?
Web Components are a suite of native browser APIs that allow you to create reusable, encapsulated custom HTML elements that work across any framework (React, Vue, Angular, or vanilla JS).
What is the Shadow DOM (`attachShadow({ mode: 'open' })`)?
Provides true DOM and CSS scoping isolation: Styles defined inside a Shadow Root never leak out into the main document • Global styles in the main document never bleed into the Shadow DOM.
How does the `loading="lazy"` attribute work on `<img>` and `<iframe>`?
Natively defers fetching off-screen images and iframes until the user scrolls near them.
What are `iframe` security attributes (`sandbox`, `allow`, `referrerpolicy`)?
Embedding untrusted third-party content (ads, widgets) introduces security vulnerabilities: sandbox: Implements extreme restrictions by default (blocks scripts, forms, popups, top-navigation).
What is the HTML Constraint Validation API?
Allows custom JavaScript validation while leveraging native browser error reporting.
Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)
26 QuestionsDeep Dive into the HTML Parser: Tokenization, Speculative Preload Scanner, and Render-Blocking Resources.
The HTML parser processes markup sequentially from top to bottom.: When it encounters a without defer/async, parsing halts completely while the network fetches and executes the file • Speculative / Preload Scanner • A secondary, lightweight thread that scans ahead in the raw HTML stream while the main parser is blocked.
Web Workers: Offloading CPU-Intensive Tasks from the Main Thread.
JavaScript runs on a single thread. Running a 3-second data encryption or image filtering computation freezes the entire UI, rendering animations choppy and blocking user clicks. Web Workers execute JavaScript on a separate background OS thread.
Service Workers: Lifecycle (`install`, `activate`, `fetch`) and Offline PWAs.
A Service Worker is an event-driven programmable network proxy sitting between the browser, the web application, and the network.
Structured Data for SEO: JSON-LD, Microdata, and Schema.org.
Search engines use structured data to display Rich Snippets (star ratings, event dates, pricing, recipe cooking times): JSON-LD (Google's Recommended Standard): Embedded inside a tag in the .
Cross-Site Scripting (XSS) Prevention: Context-Aware Escaping and Content Security Policy (CSP).
Preventing malicious scripts from stealing session cookies or redirecting users: Never use element.innerHTML with untrusted data: Always use textContent or sanitize with DOMPurify (DOMPurify.sanitize(userInput)).
The Popover API vs. `<dialog>`: Architectural Differences.
Dimension Native Popover API (popover).
Canvas (`<canvas>`) vs. SVG (`<svg>`): Performance and Architectural Trade-Offs.
SVG (Scalable Vector Graphics) • Vector-based XML DOM elements • Each shape (, ) is an individual node in the browser DOM • Bottleneck: Having > 5,000 SVG DOM nodes causes severe layout thrashing and DOM memory bloat.
File System Access API (`showOpenFilePicker`): Direct File Operations.
Replaces legacy `` by allowing web applications to read, edit, and save files directly to the user's local operating system.
Web Components Lifecycle Hooks.
The 4 native lifecycle callback methods of custom elements: connectedCallback(): Invoked each time the custom element is appended into a document-connected DOM tree • disconnectedCallback(): Invoked when removed from the DOM • adoptedCallback(): Invoked when moved to a new document (e.g. across `` boundaries).
BroadcastChannel API and Web Locks API for Multi-Tab Coordination.
BroadcastChannel: Allows different browser tabs or windows from the same origin to communicate in real-time.
The WHATWG Living Standard Governance and Feature Lifecycles.
Unlike older standards (HTML 4.01, XHTML) managed by the W3C with slow 5-year version freezes: HTML is now governed by the WHATWG (Web Hypertext Application Technology Working Group) as a continuously evolving Living Standard • Browser vendors (Google, Apple, Mozilla, Microsoft) collaborate directly.
The HTML Popover API: Native Tooltips, Menus, and Light-Dismiss.
The HTML Popover API provides built-in browser-managed popovers, menus, and toasts without requiring JavaScript libraries or z-index wars: popover attribute: Marks an element as a top-layer popover (popover="auto" or popover="manual") • popovertarget: Binds a button to toggle the popover natively.
HTML `<dialog>` Element vs Custom `<div>` Modals: Focus Trapping and `::backdrop`.
The native `` element replaces custom modal libraries: dialog.showModal(): Opens a true accessible modal in the browser's #top-layer, disables interaction with the rest of the page (inert) • dialog.show(): Opens a non-modal dialog where background elements remain interactive.
HTML5 Form Validation API: `checkValidity()`, `reportValidity()`, and `:user-invalid`.
HTML5 provides built-in client-side validation using attributes (required, pattern, minlength, type="email"): checkValidity(): Returns boolean without showing browser error bubbles • reportValidity(): Evaluates validity and triggers native validation bubbles if invalid • setCustomValidity(message): Sets custom localized error messages.
Script Loading Strategies: `async` vs `defer` vs `type="module"`.
` (Default): Blocks HTML parsing while downloading and executing immediately • : Downloads in background without blocking HTML parsing • : Downloads in background without blocking • : Behaves like defer by default, supports ES imports, and always executes in strict mode.
Resource Hints: `preload`, `prefetch`, `preconnect`, `dns-prefetch`, and `modulepreload`.
Resource hints optimize browser network loading priorities: dns-prefetch: Resolves DNS IP addresses of external domains in advance (low overhead) • preconnect: Performs DNS resolution + TCP handshake + TLS negotiation in advance (e.g. for Google Fonts CDN).
HTML Web Components: Custom Elements, Shadow DOM, and Templates.
Web Components are a suite of browser-native technologies for creating reusable custom HTML tags: Custom Elements (customElements.define): JavaScript API to define custom HTML tags (`).
Declarative Shadow DOM: Server-Side Rendering (SSR) for Web Components.
Historically, Shadow DOM required JavaScript (attachShadow()) to render, causing layout shift and rendering delays during SSR. Declarative Shadow DOM allows servers to output pre-rendered Shadow roots directly in pure HTML using ``.
Responsive Images: `<picture>` vs `<img>` with `srcset` and `sizes`.
srcset + sizes on ` (Resolution Switching): Delivers identical image content in different pixel densities (1x, 2x, 3x) or widths so mobile • (Art Direction & Format Fallback): Crops/changes image composition for small screens or serves modern formats (.avif.webp) with fallback to .jpg`.
Content Security Policy (CSP) in HTML Meta Tags: Preventing XSS.
A Content Security Policy restricts where scripts, images, styles, and frames can be loaded from. It can be delivered via HTTP header or HTML ``: default-src 'self': Only load assets from the origin domain.
Structured Data with JSON-LD and Schema.org.
JSON-LD (JavaScript Object Notation for Linked Data) embeds machine-readable semantic metadata inside ``. Search engines parse this data to display Google Rich Snippets (star ratings, event dates, recipe cooking times, FAQs).
Modern Semantic HTML Elements: `<article>`, `<section>`, `<aside>`, and `<nav>`.
Semantic HTML conveys meaning to browsers, screen readers, and search engine crawlers: : The unique central content of the document (only one visible per page) • `: Self-contained composition that makes sense independently (blog post, forum comment, tweet) • : Thematic grouping of content, typically with a heading.
Browser Parsing Pipeline: Tokenization, DOM Tree Construction, and CSSOM.
When HTML bytes arrive over the network: Conversion: Bytes are decoded into characters based on character encoding (UTF-8) • Tokenization: Characters are converted into tokens (StartTag: , EndTag: ) • DOM Tree: Tokens are turned into node objects linked in a tree hierarchy.
HTML Form Encoding Types: `enctype`.
The enctype attribute on ` defines how data is serialized: application/x-www-form-urlencoded (Default): Keys and values are URL-encoded into strings (key1=val1&key2=val2) • multipart/form-data: Mandatory when uploading files (`) • text/plain: Plain text without encoding (rarely used).
HTML Canvas vs SVG: Architectural Trade-Offs.
SVG (Scalable Vector Graphics): XML-based vector format • Canvas (``): JavaScript raster API.
Client-Side Storage: `localStorage` vs `sessionStorage` vs `IndexedDB` vs Cookies.
Cookies: ~4KB capacity • localStorage: ~5-10MB capacity per origin • sessionStorage: ~5MB capacity • IndexedDB: Hundreds of megabytes / gigabytes.