NEWNew questions added!Explore now

Interview preparation guide · Updated 2026

HTML and CSS Interview Questions with Answers (2026)

HTML and CSS interviews test whether you can build interfaces that are semantic, accessible, responsive, and predictable across browsers. Be ready to explain element choice, the cascade, layout algorithms, intrinsic sizing, and rendering performance. The best answers connect platform rules to a small UI example or debugging scenario.

By FrontendPro Editorial Team Last reviewed August 8, 2026

What you need to know

Use these topic clusters as a checklist. Each answer should define the concept, show where it matters, and include a concrete example or trade-off.

Practice questions with answers

Open a question for a direct explanation, detailed answer, related concepts, and runnable code where the problem includes a coding exercise.

CSS interview questions

  1. How do the different ways of hiding an element differ for accessibility?Intermediate · Answer and explanation
  2. What is the difference between auto-fit and auto-fill in Grid?Advanced · Answer and explanation
  3. How do you implement dark mode properly in CSS?Intermediate · Answer and explanation
  4. What is BEM and which problem does it solve?Intermediate · Answer and explanation
  5. What does :has() make possible that CSS previously couldn't do?Advanced · Answer and explanation
  6. Why should you animate only transform and opacity?Advanced · Answer and explanation
  7. How do container queries differ from media queries?Intermediate · Answer and explanation
  8. What is margin collapsing and how do you prevent it?Intermediate · Answer and explanation
  9. What is a stacking context, and why can z-index: 9999 still be covered?Advanced · Answer and explanation
  10. How do CSS custom properties differ from SCSS variables?Intermediate · Answer and explanation
  11. What is the difference between a pseudo-class and a pseudo-element?Basic · Answer and explanation
  12. What are the ways to center an element on both axes?Basic · Answer and explanation
  13. When do you use px, em, rem, %, vw/vh and ch?Basic · Answer and explanation
  14. How do the position values differ?Basic · Answer and explanation
  15. When should you use Flexbox versus Grid?Intermediate · Answer and explanation
  16. How is CSS specificity calculated?Intermediate · Answer and explanation
  17. What is the box model, and what does box-sizing: border-box change?Basic · Answer and explanation

HTML interview questions

  1. What problems do <dialog> and <details> solve natively?Intermediate · Answer and explanation
  2. How do you embed third-party content in an <iframe> safely?Advanced · Answer and explanation
  3. Compare localStorage, sessionStorage and cookiesIntermediate · Answer and explanation
  4. What does the <meta name="viewport"> tag do?Basic · Answer and explanation
  5. When do you need ARIA, and what is the first rule of ARIA?Intermediate · Answer and explanation
  6. How do you serve responsive images with srcset, sizes and <picture>?Intermediate · Answer and explanation
  7. How do plain <script>, defer and async differ?Intermediate · Answer and explanation
  8. What form validation does HTML provide out of the box?Intermediate · Answer and explanation
  9. What are data-* attributes used for?Basic · Answer and explanation
  10. What is the difference between the id and class attributes?Basic · Answer and explanation
  11. What is the difference between block, inline and inline-block elements?Basic · Answer and explanation
  12. What are semantic HTML elements and why should you use them?Basic · Answer and explanation

How to prepare efficiently

Do not memorize a long script. Practice a repeatable answer structure: direct answer, short example, edge case, and trade-off.

  • Start with native HTML behavior before reaching for ARIA or JavaScript.
  • Draw the box and identify its containing block when debugging layout.
  • Explain why Flexbox or Grid fits the problem instead of naming one as universally better.
  • Test keyboard navigation, zoom, long text, reduced motion, and narrow screens.
  • Use browser DevTools to inspect computed styles, layout overlays, and accessibility information.