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
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, andheight. - 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
widthandheight. Horizontalmarginandpaddingwork, 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. Customwidth,height, and verticalmargin/paddingare ignored.display: inline-block: Elements flow inline but behave like block-level elements. They respect customwidth,height, and verticalmargin/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
alttext 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
Browse All HTML Questions by Difficulty
Easy50 Questions
Core concepts, definitions, basic syntax, and first principles expected in round 1 screening.
VIEW FULL LIST
Medium50 Questions
Real-world mechanisms, state management, edge cases, performance trade-offs, and practical coding.
VIEW FULL LIST
Hard50 Questions
Deep runtime internals, memory models, distributed design, concurrency failure modes, and architectural decisions.
VIEW FULL LIST
INTERNAL LINKING & DEPENDENCIES