Frontend Developer Interview Questions and Answers

Frontend developer interview questions with answers: HTML and accessibility, CSS layout, JavaScript, browser rendering, performance and Core Web Vitals, security, frameworks and frontend system design.

Updated November 20, 2026 31 questions 7 min read

Key takeaways

  • Frontend interviews cover HTML, CSS, JavaScript and a framework, plus how the browser renders pages.
  • Performance (Core Web Vitals) and accessibility questions are now standard, not optional.
  • Expect a live UI task: a component with state, async data and edge cases.
  • Senior roles add frontend system design: architecture, state, caching, rendering strategies.
Contents

Frontend interviews go beyond a framework: interviewers check HTML, CSS and JavaScript fundamentals, browser behavior, performance, accessibility and security, and often a live UI task. Below are 31 common questions grouped by topic and level.

What frontend interviews cover

Typical topic mix in a frontend interview loop

Editorial estimate for a mid-level role.

4–5rounds
  • JavaScript and framework30%
  • Live UI coding25%
  • HTML, CSS and accessibility15%
  • Performance and browser15%
  • Frontend system design10%
  • Security5%

Core Web Vitals thresholds

Google's “good” thresholds (75th percentile of page loads)
≤ 2.5 s
LCP: Largest Contentful Paint
loading
≤ 200 ms
INP: Interaction to Next Paint
responsiveness
≤ 0.1
CLS: Cumulative Layout Shift
visual stability

Source: web.dev: Web Vitals

See also React and JavaScript interview questions.

HTML and accessibility

1Why does semantic HTML matter?

Junior

Elements like header, nav, main, button and label describe meaning, which helps screen readers, keyboard navigation, SEO and maintainability. A div with a click handler is not a button: it lacks focus, keyboard support and the right role.

2How do you make a website accessible?

Mid

Use semantic HTML, label every form field, provide text alternatives for images, ensure sufficient color contrast, make everything work with a keyboard with visible focus, manage focus in dialogs, and use ARIA only when native HTML can’t express something. Test with a screen reader and automated tools like axe.

3What should a modal dialog do for accessibility?

Mid

Move focus into the dialog when it opens, trap focus inside it, close on Escape, return focus to the trigger when it closes, have an accessible name (aria-labelledby), and hide background content from assistive technology. The native <dialog> element handles much of this.

4async vs defer on script tags?

Junior

Both download scripts without blocking HTML parsing. async executes as soon as the script is downloaded, in any order. defer executes after parsing finishes, in document order. Use defer for app scripts that depend on the DOM or on each other.

CSS

5Explain the CSS box model.

Junior

Every element is content plus padding, border and margin. With box-sizing: content-box (the default), width sets only the content; with border-box, it includes padding and border, which makes layouts easier. Most projects set border-box globally.

6How does CSS specificity work?

Junior

Inline styles beat IDs, which beat classes, attributes and pseudo-classes, which beat element selectors. If specificity is equal, the later rule wins. !important overrides normal rules and should be rare. Cascade layers (@layer) give another, explicit way to order styles.

7Flexbox vs Grid?

Junior

Flexbox is one-dimensional: items along a row or column, great for toolbars and aligning content. Grid is two-dimensional: rows and columns together, great for page layouts and card grids. They are often combined.

8How do you center an element horizontally and vertically?

Mid
.parent { display: grid; place-items: center; }
/* or */
.parent { display: flex; justify-content: center; align-items: center; }

9What are container queries?

Mid

Styles that respond to the size of a parent container rather than the viewport (@container (min-width: 400px)). They make components truly reusable, since a card can adapt whether it’s in a sidebar or the main column.

10How do you avoid layout shifts caused by CSS and media?

Mid

Reserve space for images, videos and ads with width/height or aspect-ratio, avoid inserting content above existing content, use font-display with fallback fonts sized to match, and animate with transform instead of layout properties.

Get Frontend answer points in real time during your interview

Sottena listens to the interviewer, detects each question and shows short answer points in about a second. 150 free credits, no card required.

Browser and rendering

11How does a browser render a page?

Mid

It parses HTML into the DOM and CSS into the CSSOM, combines them into the render tree, calculates layout (sizes and positions), paints pixels and composites layers. JavaScript can block parsing and trigger recalculations.

12What are reflow and repaint, and how do you minimize them?

Mid

Reflow (layout) recalculates geometry; repaint redraws pixels. Reflow is more expensive. Avoid reading layout values (offsetHeight) right after writing styles in a loop, batch DOM changes, and animate transform and opacity, which can run on the compositor.

13What is the critical rendering path?

Junior

The steps the browser must complete before showing the first content: downloading and parsing HTML, CSS and blocking scripts. Optimize it by inlining critical CSS, deferring non-critical scripts, and reducing render-blocking resources.

JavaScript in the browser

14Explain the event loop.

Mid

JavaScript runs on one thread. After synchronous code, the browser runs all microtasks (promise callbacks), then one macrotask (timer, event), then may render. Long tasks block input and rendering. More detail in our JavaScript interview questions.

15What is event delegation?

Junior

One listener on a parent handles events from many children, using event.target. It reduces the number of listeners and works for elements added later.

16Where should you store authentication tokens on the web?

Mid

Prefer HttpOnly, Secure, SameSite cookies, which JavaScript can’t read, protecting tokens from XSS. Tokens in localStorage are readable by any script on the page. Pair cookies with CSRF protection.

Performance

17What are Core Web Vitals?

Mid

Google’s user-experience metrics: LCP (Largest Contentful Paint, loading), INP (Interaction to Next Paint, responsiveness) and CLS (Cumulative Layout Shift, visual stability). Google’s “good” thresholds are LCP under 2.5 s, INP under 200 ms and CLS under 0.1, measured at the 75th percentile of real users.

18How do you improve LCP?

Mid

Serve the LCP image or text quickly: optimize and correctly size images (AVIF/WebP, srcset), preload the hero image, avoid lazy-loading it, reduce server response time, use a CDN, and remove render-blocking CSS and JavaScript.

19How do you reduce JavaScript bundle size?

Mid

Analyze the bundle, split code by route with dynamic import(), tree-shake unused exports, replace heavy dependencies, avoid shipping polyfills to modern browsers, and move work to the server where possible.

20How do you improve INP?

Senior

Break up long tasks (yield to the main thread), reduce the work done in event handlers, defer non-urgent updates (for example with React’s useTransition), avoid heavy re-renders, and move expensive computation to Web Workers.

Security

21What is XSS, and how do you prevent it?

Mid

Cross-site scripting injects malicious scripts into a page. Prevent it by escaping output (frameworks do this by default), avoiding innerHTML and dangerouslySetInnerHTML with untrusted data, sanitizing HTML when you must render it, and adding a Content Security Policy.

22What is CORS?

Mid

A browser mechanism that lets a server declare which other origins may read its responses, via headers like Access-Control-Allow-Origin. Non-simple requests trigger a preflight OPTIONS request. CORS protects users’ data in browsers; it is not server-side access control.

23What is CSRF, and how is it prevented?

Mid

Cross-site request forgery tricks a logged-in user’s browser into sending an unwanted request with their cookies. Prevent it with SameSite cookies, CSRF tokens for state-changing requests, and checking the Origin header.

Frameworks and state

24Why use a framework like React, Vue or Angular?

Mid

They give a component model and declarative rendering that keep complex UIs maintainable, plus ecosystems for routing, state and testing. The trade-offs are bundle size and abstraction cost. Be ready to go deep on the one you use; see our React questions.

25How do you manage server data on the frontend?

Mid

Treat it as server state with a cache library (TanStack Query, SWR, RTK Query) that handles loading, caching, deduplication, background refetching and invalidation. Keep client-only UI state separate and as local as possible.

26SSR vs SSG vs CSR vs streaming: how do you choose?

Senior

Static generation for content that changes rarely (fastest, cheapest). Server rendering for personalized or frequently updated pages that need SEO and fast first paint. Client rendering for app-like dashboards behind login. Streaming SSR sends parts of the page as they’re ready. Most modern apps mix them per route.

Testing and tooling

27How do you test frontend code?

Mid

Unit tests for logic, component tests with Testing Library that interact like a user, end-to-end tests (Playwright, Cypress) for critical flows, and visual regression tests for design systems. Mock network calls at the boundary, for example with MSW.

28What does a bundler do?

Junior

It resolves imports, transforms code (TypeScript, JSX, modern syntax), bundles and splits it into files, optimizes assets, and provides a dev server with hot reload. Common tools are Vite, webpack and Turbopack.

Frontend system design

29Design an autocomplete search component.

Senior

Debounce input, cancel outdated requests (AbortController), cache recent results, handle loading, empty and error states, support keyboard navigation and the ARIA combobox pattern, highlight matches, and limit results. Discuss server-side ranking, rate limits and analytics.

30Design a news feed with infinite scroll.

Senior

Cursor-based pagination API, a server-state cache, virtualized list rendering, prefetching the next page near the bottom, optimistic updates for likes, image lazy loading with reserved space, restoring scroll position on navigation, and handling new items arriving at the top.

31How would you build a design system?

Senior

Start with design tokens (colors, spacing, typography), build accessible primitives (button, input, dialog), document them with examples, version and publish them as a package, add visual regression tests, and agree on a contribution and deprecation process with product teams.

How to prepare

  1. Build UI tasks under time pressureAutocomplete, modal, tabs, infinite list, form with validation.
  2. Learn the browser, not only the frameworkRendering, event loop, caching, security headers.
  3. Measure performanceBe ready to explain Core Web Vitals and how you improved one.
  4. Practice accessibility basicsKeyboard support, focus management, labels and ARIA patterns.
  5. Prepare a frontend design answerData fetching, state, rendering strategy and trade-offs.

Get answer points in real time during your interview

Sottena listens to the interviewer, detects each question and shows short answer points in about a second. 150 free credits, no card required.

Related interview questions