HTML & CSS interview questions

Semantic HTML, box model, Flexbox vs Grid, specificity, positioning, responsive design, accessibility and the classic “why doesn’t this CSS work” bugs.

Readiness: 0 of 18 nailed

How to use this page: 1. Read a question2. Type your answer3. Check with AI4. Open the model answer5. Timed drill when you’re 70% ready

HTML

FoundationConcept

What is semantic HTML and why does it matter?

JuniorConcept

Which HTML elements matter most for SEO?

Layout

FoundationPredict the output

How wide is this box on screen?

.box {
  width: 200px;
  padding: 20px;
  border: 5px solid;
}
JuniorConcept

When do you use Flexbox and when Grid?

Mid-levelIt’s broken: why?

A dropdown has z-index: 9999 but still appears behind another element. Why?

FoundationConcept

Explain static, relative, absolute, fixed and sticky positioning.

FoundationWrite it by hand

Center a div horizontally and vertically.

Mid-levelIt’s broken: why?

Two stacked paragraphs each have margin: 20px, but the gap is 20px, not 40px. Why?

Cascade

JuniorIt’s broken: why?

Why is the button still blue?

#header .btn { color: blue; }
.btn.primary { color: red; }
/* <div id="header"><a class="btn primary">Buy</a></div> */
JuniorPredict the output

Which color wins for <p id="intro" class="lead">?

p { color: red; }
.lead.text { color: blue; }
#intro { color: green; }
FoundationConcept

Pseudo-classes vs pseudo-elements?

Mid-levelConcept

What are CSS cascade layers (@layer)?

Responsive

JuniorConcept

How do you make a site responsive? What is mobile-first?

JuniorConcept

px vs em vs rem vs % vs vw?

Accessibility

Mid-levelReal-world scenario

How do you make a modal dialog accessible?

JuniorReal-world scenario

How do you make a form accessible?

Performance

Mid-levelIt’s broken: why?

The page content jumps while loading (bad CLS). What causes it?

Mid-levelConcept

Which CSS properties are cheap to animate?

Also prepare