Lesson 5 of 9
HTML Interview Questions
HTML interview questions test your understanding of semantic markup, accessibility, performance, and browser behavior. Companies ask these in frontend developer interviews alongside CSS and JavaScript questions. Knowing HTML deeply sets you apart from candidates who only know frameworks.
Common Interview Questions
- What is semantic HTML? Give 5 examples - <header>, <nav>, <main>, <article>, <footer>. Semantic elements describe the meaning of content for search engines and screen readers.
- What is the difference between <div> and <section>? - <div> has no semantic meaning (generic wrapper). <section> represents a thematic grouping with a heading. Use <section> when content has meaning; <div> for layout only.
- How does the browser render HTML? - Parse HTML β Build DOM tree β Parse CSS β Build CSSOM β Combine into Render tree β Layout (geometry) β Paint (pixels) β Composite (layers).
- What are void/self-closing elements? - Elements with no closing tag: <img>, <br>, <hr>, <input>, <meta>, <link>. They can't contain children.
- Explain the purpose of the DOCTYPE - Tells browser to use standards mode vs quirks mode. Without it, browsers use legacy rendering that breaks modern CSS.
- What is the difference between localStorage and sessionStorage? - localStorage persists forever (until cleared). sessionStorage clears when the tab closes. Both store up to 5-10MB as key-value strings.
- How do you optimize a webpage's performance? - Lazy load images, defer scripts, preload critical resources, compress images (WebP), use CDN, minimize CSS, enable GZIP compression.
- What are Web Components? - Custom reusable HTML elements using Custom Elements API, Shadow DOM (encapsulation), and HTML Templates (<template>/<slot>).
Warning
Don't just memorize interview answers - understand the concepts deeply. Interviewers follow up with 'why' and 'when would you use this?' questions. For example, knowing that <section> needs a heading is good, but explaining WHY (document outline for accessibility) shows real understanding.
Prepare for technical interviews with deep knowledge of semantics, a11y, and DOM
Key Takeaways
- HTML interview questions test your understanding of semantic markup, accessibility, performance, and browser behavior.
- What is semantic HTML? Give 5 examples - <header>, <nav>, <main>, <article>, <footer>. Semantic elements describe the meaning of content for search engines and screen readers.
- What is the difference between <div> and <section>? - <div> has no semantic meaning (generic wrapper). <section> represents a thematic grouping with a heading. Use <section> when content has meaning; <div> for layout only.
- How does the browser render HTML? - Parse HTML β Build DOM tree β Parse CSS β Build CSSOM β Combine into Render tree β Layout (geometry) β Paint (pixels) β Composite (layers).
Finished this lesson?