HTML & CSS Interview Questions (2026): By Level, With Model Answers

How to use this

HTML and CSS are underestimated until a layout breaks in production. These questions separate people who memorised properties from those who understand the model.

Hiring a HTML & CSS developer is easy. Telling a real one from a convincing résumé is the hard part — and it’s most of what we do. These are grouped by level, because the same question that stretches a junior is a warm-up for a senior.

Junior HTML & CSS interview questions

0–2 years

Fundamentals.

What is the CSS box model?

What a strong answer covers

Every element is a box of content, padding, border and margin; box-sizing: border-box makes width include padding and border.

Red flag

Can’t explain why widths overflow with padding.

What is the difference between block, inline and inline-block?

What a strong answer covers

Block elements take full width and stack; inline flow within text and ignore width/height; inline-block flows but accepts dimensions.

Red flag

Sets width on an inline element and is confused it’s ignored.

What is semantic HTML and why does it matter?

What a strong answer covers

Using meaningful elements (header, nav, article) for structure, aiding accessibility and SEO.

Red flag

Builds everything from divs.

What is the difference between id and class?

What a strong answer covers

An id is unique per page and higher specificity; classes are reusable; prefer classes for styling.

Red flag

Styles with ids everywhere, creating specificity wars.

What is the difference between rem, em, px and %?

What a strong answer covers

px is absolute; em is relative to the element’s font size; rem to the root; % to the parent.

Red flag

Uses only px and can’t scale accessibly.

How does flexbox work?

What a strong answer covers

A one-dimensional layout: a flex container aligns and distributes children along a main and cross axis.

Red flag

Reaches for floats for everything.

What is the difference between visibility: hidden and display: none?

What a strong answer covers

display:none removes the element from layout; visibility:hidden hides it but keeps its space.

Red flag

Uses them interchangeably.

How do you make a site responsive?

What a strong answer covers

Fluid layouts, relative units, flexbox/grid and media queries; mobile-first is a common approach.

Red flag

Fixes one desktop width in pixels.

Mid-level HTML & CSS interview questions

2–5 years

Layout and specificity.

When do you use CSS Grid vs Flexbox?

What a strong answer covers

Grid for two-dimensional layouts (rows and columns), Flexbox for one-dimensional distribution; they compose well together.

Red flag

Forces complex 2D layouts with nested flexboxes.

How does specificity work?

What a strong answer covers

Inline > id > class/attribute/pseudo-class > element; more specific wins, and !important overrides — a smell if overused.

Red flag

Fixes everything with !important.

What is the difference between position: relative, absolute, fixed, sticky?

What a strong answer covers

Relative offsets from its normal spot; absolute positions to the nearest positioned ancestor; fixed to the viewport; sticky toggles between relative and fixed.

Red flag

Cannot predict what an absolutely-positioned element anchors to.

How does the cascade and inheritance work?

What a strong answer covers

Styles cascade by origin, specificity and order; some properties inherit (color, font) and others don’t.

Red flag

Expects every property to inherit.

What causes layout shift and how do you prevent it?

What a strong answer covers

Images or ads without reserved dimensions, late-loading fonts; reserve space and set width/height to improve CLS.

Red flag

Ignores CLS and content jumps around.

How do transitions and animations differ?

What a strong answer covers

Transitions animate between two states on change; keyframe animations define multi-step sequences that can loop.

Red flag

Uses JS timers where CSS would do.

What are pseudo-classes vs pseudo-elements?

What a strong answer covers

Pseudo-classes target states (:hover, :focus); pseudo-elements target parts (::before, ::first-line).

Red flag

Confuses : and :: usage.

How do you handle cross-browser differences?

What a strong answer covers

Progressive enhancement, feature queries (@supports), sensible resets and testing on target browsers.

Red flag

Assumes it works everywhere because it works in one browser.

Senior HTML & CSS interview questions

5+ years

Architecture, performance and a11y.

How do you architect CSS at scale?

What a strong answer covers

A methodology (BEM, utility-first, CSS modules or scoped styles) to avoid specificity wars and global collisions.

Red flag

Global styles with deep selectors and no system.

How do you optimise CSS performance?

What a strong answer covers

Minimise render-blocking CSS, avoid expensive selectors and layout thrash, and be mindful of what triggers reflow vs repaint.

Red flag

No awareness of reflow/paint costs.

What CSS properties are cheap to animate?

What a strong answer covers

transform and opacity are compositor-friendly; animating layout properties like width/top is costly.

Red flag

Animates left/width and causes jank.

How do you build accessible interfaces?

What a strong answer covers

Semantic markup, keyboard operability, focus management, sufficient contrast, and ARIA only when native semantics fall short.

Red flag

Bolts ARIA onto div soup instead of using real elements.

What are container queries and custom properties good for?

What a strong answer covers

Container queries style based on a component’s own size; custom properties enable theming and runtime-dynamic values.

Red flag

Only knows global media queries and Sass variables.

How do you manage theming and dark mode?

What a strong answer covers

CSS custom properties with a theme switch, respecting prefers-color-scheme, and sufficient contrast in both themes.

Red flag

Hardcodes colours and can’t theme.

How do you prevent and debug z-index and stacking issues?

What a strong answer covers

Understand stacking contexts (created by position, opacity, transform) rather than escalating z-index numbers.

Red flag

Sets z-index: 9999 and hopes.

How do you ship CSS that’s maintainable across a team?

What a strong answer covers

Conventions, linting, design tokens, scoped or modular styles, and documentation so styles don’t rot.

Red flag

Everyone adds ad-hoc overrides.

Skip the screening entirely.We vet HTML & CSS engineers so you don’t have to — embed one in your team, or have us build it.

Hire HTML & CSS developersCompare us

Build and score a full interview with our free interview scorecard tool, browse the full question hub, or see how we interview engineers.

Share