D
DevPrepSystematic Prep
DEVPREP CODEX · #09

HTML Interview Questions

150 curated questions graded from Foundations (Easy) to Practical Patterns (Medium) and Internals & Architecture (Hard).

TOTAL QUESTIONS

150

THEORY QUESTIONS

150

IMPLEMENTATION FOLIOS

0

FREE QUESTIONS

5 / Level

Easy Level·50 Questions Total

Foundations & Core Concepts

Open Full Easy List
Q1What is the HTML DocType declaration, and why is it needed?
  • Definition: <!DOCTYPE html> is a preamble that instructs the browser about the version of HTML the page is written in.
  • Purpose: It prevents the browser from entering quirks mode (which emulates bugs of older browsers) and forces it to render the document in standards mode according to W3C specifications.
  • Syntax: In HTML5, it is extremely compact and case-insensitive: <!DOCTYPE html>.
Q2What are semantic elements, and why are they preferred over non-semantic elements?
  • Definition: Semantic elements clearly describe their meaning to both the browser and the developer (e.g., <header>, <article>, <nav>), whereas non-semantic elements say nothing about their content (e.g., <div>, <span>).
  • Benefits:
    • Accessibility (a11y): Screen readers can easily build the document outline and let users jump to sections.
    • SEO: Search engine web crawlers prioritize content inside relevant semantic tags.
    • Maintainability: Creates a cleaner, more readable code structure for development teams.
Q3Explain the difference between block-level and inline elements.
  • Block-level:
    • Flow: Starts on a new line and takes up the full width of its parent container.
    • Box Model: Respects vertical and horizontal margin, padding, width, and height.
    • Examples: <div>, <p>, <h1>-<h6>, <ul>, <article>.
  • Inline:
    • Flow: Does not start on a new line; fits horizontally next to other inline elements.
    • Box Model: Ignores width and height. Horizontal margin and padding work, but vertical ones do not affect surrounding element flow.
    • Examples: <span>, <a>, <strong>, <em>, <img>.
Q4What is the difference between inline and inline-block display values?
  • display: inline: Elements flow inline. Custom width, height, and vertical margin/padding are ignored.
  • display: inline-block: Elements flow inline but behave like block-level elements. They respect custom width, height, and vertical margin/padding.
Q5What does the `alt` attribute do in an `<img>` tag, and why is it essential?
  • Function: Specifies an alternate text description for an image if it fails to load.
  • Accessibility: Screen readers read this text to visually impaired users, making the website accessible.
  • SEO: Search engines index the alt text to understand the image content, improving search visibility.
45 More Easy Questions Locked

Unlock the complete HTML Easy question bank

Get instant access to all 50 questions, in-depth model answers, code sandboxes, and all 27+ technologies for a single one-time payment.

Unlock All — One-time payment · Lifetime access
DEDICATED LEVEL PAGES

Browse All HTML Questions by Difficulty

INTERNAL LINKING & DEPENDENCIES

Related Technologies to HTML

CAREER PATHWAYS

HTML is a key requirement for these engineering roles:

HTML Interview Questions — Easy, Medium & Hard | DevPrep | DevPrep