Interview guide

Frontend Developer Interview Questions and Sample Answers

For frontend and UI developers preparing for JavaScript, CSS, accessibility, performance and React rounds. Each question explains what the interviewer is checking, with practical tips and sample answers you can say out loud and adapt.

14 questions · Updated 24 November 2026

Frontend interviews are hard to bluff. An interviewer can ask why a page jumps while it loads, why a click feels slow, or what a screen reader announces for your button, and the answer depends on understanding the browser, not just a framework.

This guide goes deeper than general coding questions: how the browser renders a page, the event loop, closures, CSS layout, accessibility, Core Web Vitals, React state and effects, and choosing between client and server rendering. For broader topics such as complexity and general system design, see the software engineer guide. The sample answers use [placeholders] for your own projects and results.

If you’re early in your career, focus on JavaScript fundamentals, semantic HTML, CSS layout and one project you can explain line by line. With more experience, expect more questions on architecture, performance and how you work with design and backend teams.

How the interview usually goes

  • Recruiter screen: your experience, the frameworks you use, the kind of products you’ve built, notice period and salary expectations.
  • JavaScript fundamentals: closures, this, promises and the event loop, often with a short snippet where you predict the output.
  • Practical UI coding: building a component such as a modal, tabs, an autocomplete or a data table in a shared editor, or as a take-home task. Structure, state handling, accessibility and edge cases usually matter more than pixel-perfect styling.
  • Frontend system design, mostly for mid-level and senior roles: for example, a news feed, a dashboard or a shared component library, covering data fetching, rendering strategy, performance and accessibility.
  • Behavioural or hiring-manager round: working with designers, product managers and backend engineers, handling feedback and shipping to deadlines.

Browser and JavaScript fundamentals

These questions check whether you understand what the browser actually does with your code. Explain each idea plainly, then give one example from real work.

How does the browser turn HTML, CSS and JavaScript into pixels on the screen?

What they’re checking: This is the critical rendering path. Interviewers want to see that you know what blocks rendering, because most loading-performance fixes follow from it.

  • Name the stages in order: DOM, CSSOM, render tree, layout, paint, composite.
  • Know what blocks what: CSS blocks rendering, and classic scripts without defer or async block HTML parsing.
  • Link each stage to a fix you have made, such as deferring scripts or making the main image load earlier.
Sample answer

The browser parses the HTML into the DOM as it streams in. When it finds a stylesheet, it fetches it and builds the CSSOM. CSS is render-blocking, because painting without it would flash unstyled content. A classic script without defer or async pauses parsing until it’s downloaded and run, since it might change the document. With the DOM and CSSOM ready, the browser builds a render tree of visible elements and their computed styles, runs layout to work out sizes and positions, paints pixels into layers and composites those layers on screen. In practice, that’s why I keep critical CSS small, defer non-essential JavaScript and make sure the main image is in the initial HTML. It’s also why animating transform and opacity is cheaper than animating width or top: the browser can often skip layout and paint.

Explain the event loop. Where do promises and async/await fit in?

What they’re checking: Async bugs, frozen interfaces and slow interactions all come back to the event loop. Interviewers often follow up with a snippet and ask you to predict the order of the output.

  • Separate the call stack, the task queue and the microtask queue; promise callbacks are microtasks.
  • Explain that await pauses only the async function it’s in, not the main thread.
  • Connect it to the user: a long task blocks input and rendering, which makes the page feel unresponsive.
Sample answer

JavaScript in the browser runs on one main thread with a single call stack. Timers, network requests and user events are handled by the browser, and their callbacks are queued as tasks. The event loop takes one task, runs it to completion, then runs every queued microtask, which is where promise callbacks go, before the browser can render and move on to the next task. So if a script calls setTimeout with zero delay and then a promise’s then, the promise callback runs first. An async function runs synchronously until its first await; the rest resumes as a microtask once the awaited promise settles, and the thread is free in between. The practical lesson is that long synchronous work, including an endless chain of microtasks, blocks clicks, typing and rendering, so I split heavy work into smaller pieces.

What is a closure? Where have you used one?

What they’re checking: Closures sit behind event handlers, callbacks, React hooks and many subtle bugs. Interviewers want a clear explanation and a real use, not a textbook definition.

  • Define it in one sentence, then give a practical use such as a debounce function or a counter with private state.
  • Mention a pitfall you’ve met: the old var-in-a-loop bug, or a stale value captured by a React callback.
  • Keep any code to a line or two; the explanation matters more.
Sample answer

A closure is a function bundled with the variables from the scope where it was created. It keeps access to them even after the outer function has returned. A debounce helper is a good example: it keeps a timer ID in a variable inside the outer function, and the function it returns clears and restarts that timer on every call. Nothing outside can touch the timer, so it’s effectively private state. Closures also explain a classic bug: with var in a for loop, every callback shares one variable and sees its final value, whereas let creates a fresh binding for each iteration. In React, the same idea causes stale values: on [project], [the bug — for example, an interval callback kept reading the state from the render it was created in], and I fixed it by [your fix — for example, using a functional state update].

How is the value of this decided in JavaScript?

What they’re checking: Losing this when a method is passed around is a common bug. Interviewers check that you know the rules rather than guessing.

  • Lead with the key idea: for regular functions, this depends on how the function is called, not where it was written.
  • Go through the cases in order: method call, plain call, new, explicit binding, then arrow functions as the exception.
  • Practise with two or three short snippets until you can predict the result without hesitating.
Sample answer

For a regular function, this is decided at call time by how the function is called. Called as a method, like user.greet(), it’s the object before the dot. Called on its own, it’s undefined in strict mode, and modules and classes are always strict; in old non-strict scripts it falls back to the global object. With new, this is the newly created object, and call, apply and bind let me set it explicitly. Arrow functions are the exception: they don’t have their own this and use the one from the surrounding code, which is why they work well as callbacks inside methods. The bug I see most is passing a method as a callback, for example to setTimeout or an event listener, and losing the object. Binding the method or wrapping the call in an arrow function fixes it.

CSS, layout and accessibility

Flexbox or grid: how do you decide?

What they’re checking: Interviewers want to know you choose layout tools deliberately, not by habit, and that your CSS knowledge is current.

  • Flexbox is one-dimensional and driven by content; grid is two-dimensional and driven by the layout you define.
  • They combine well: grid for the page or card layout, flexbox inside each component.
  • Modern features worth knowing: gap in both, subgrid, and container queries, all supported in current major browsers.
Sample answer

I think of flexbox as one-dimensional: it lays items out in a row or a column and lets their content decide how space is shared. It’s ideal for a navigation bar, a row of buttons, or lining up an icon with text. Grid is two-dimensional: I define rows and columns first and place items into them, so things align in both directions. I use it for page layouts, forms where labels and fields should line up, and card galleries, where repeat with auto-fill and minmax gives a responsive layout without media queries. In practice I combine them: grid for the overall structure and flexbox inside components. When a component should adapt to the space it’s given rather than the viewport, I use a container query, and subgrid helps when nested items need to line up with the parent grid.

How does CSS specificity work, and how do you stop styles fighting each other?

What they’re checking: Specificity battles lead to fragile CSS and a growing pile of !important. They want to know you understand the cascade and can keep a large codebase maintainable.

  • Know the order the cascade checks: importance, inline styles, cascade layers, specificity (IDs, then classes, attributes and pseudo-classes, then elements) and finally source order.
  • Keep specificity low and flat: single classes, no IDs for styling, and !important only as a last resort.
  • Mention modern tools: @layer to order resets, third-party and component styles, and :where() for zero-specificity defaults.
  • Scoped styles, such as CSS Modules or component-scoped CSS, reduce collisions when many people work on the same app.

How do you make a component accessible?

What they’re checking: Accessibility is part of doing the job properly. Interviewers want practical habits you apply every day, not a list of ARIA attributes.

  • Start with semantic HTML: a real button, a label tied to each input, headings in order, and landmarks such as main and nav.
  • Cover keyboard use and focus: everything reachable with Tab, a visible focus indicator, and focus managed in dialogs.
  • Use ARIA sparingly, only for what HTML can’t express, and say how you test: keyboard only, a screen reader, and automated checks, which catch only some issues.
Sample answer

I start with semantic HTML, because native elements bring keyboard support and meaning for assistive technology for free. A button is a button, not a div with a click handler, and every input has a visible, connected label. Then I check the keyboard: can I reach and operate everything with Tab, Enter, Space and Escape, is focus always visible, and is the order logical? In a modal, focus should move inside, stay there while it’s open and return to the trigger on close; the native dialog element, opened as a modal, handles much of that. I check colour contrast against WCAG AA, which is 4.5 to 1 for normal text, and never rely on colour alone to show an error. ARIA comes last, where HTML can’t express something, like aria-expanded on a menu button. Finally, I test with a keyboard and a screen reader, not just an automated checker.

Performance, React and rendering

These questions separate people who have shipped and maintained real interfaces from those who have only built tutorials. Measure first, then explain the trade-off behind each fix.

What are Core Web Vitals, and how would you improve them?

What they’re checking: These metrics describe how real users experience loading, responsiveness and visual stability. Interviewers check that your knowledge is current and that you measure before you optimise.

  • Know the three: LCP for loading, INP for responsiveness and CLS for visual stability. INP replaced First Input Delay in March 2024, so don’t describe FID as current.
  • The “good” thresholds are LCP within 2.5 seconds, INP within 200 milliseconds and CLS of 0.1 or less, measured at the 75th percentile of real page visits.
  • Distinguish field data from real users and lab data from a test run. Lab tests can’t measure INP directly because it needs real interactions, so they rely on proxies such as Total Blocking Time.
Sample answer

Core Web Vitals are three metrics measured from real users. Largest Contentful Paint is how quickly the main content, usually a hero image or heading, appears. Interaction to Next Paint, which replaced First Input Delay in 2024, is how quickly the page visibly responds to clicks, taps and key presses throughout the visit. Cumulative Layout Shift is how much content jumps around unexpectedly. To improve LCP, I make sure the main image is in the initial HTML and not lazy-loaded, give it a high fetch priority, serve it compressed at the right dimensions, and cut render-blocking resources and slow server responses. For INP, I break up long tasks, keep event handlers light and defer non-urgent work. For CLS, I set width and height on images and embeds, reserve space for anything injected later, and use fallback fonts with matching metrics. Then I compare real-user data before and after.

How do you decide where state lives in a React app, and when do you use an effect?

What they’re checking: Misplaced state and unnecessary effects cause many React bugs and wasted renders. Interviewers want to hear a clear mental model, not a list of hooks.

  • Keep state minimal and derive everything else during render; a filtered list doesn’t need its own state.
  • Effects are for synchronising with something outside React, such as a subscription, a timer or a browser API. Logic triggered by a user action belongs in the event handler.
  • Clean up subscriptions, timers and in-flight requests. In development, Strict Mode runs effects an extra time to expose missing cleanup.
Sample answer

I treat state as the smallest set of changing values the UI depends on. Anything I can calculate from props or other state, like a filtered list or a basket total, I compute during render instead of storing, so it can’t drift out of sync. State lives in the closest common parent of the components that need it. If many distant components read the same value, such as the current user or theme, context makes sense. Server data is different: it’s really a cache of the backend, so I use the framework’s data loading or a data-fetching library that handles caching and refetching. Effects are for synchronising with something outside React, like a WebSocket subscription or a third-party widget. If I’m responding to a user action, the logic belongs in the event handler. And any effect that starts something gets a cleanup function to stop it.

Client-side rendering, server-side rendering or static generation: how do you choose?

What they’re checking: Rendering strategy affects speed, search visibility, hosting cost and complexity. Interviewers look for trade-offs per page rather than one answer for everything.

  • Know what hydration is: the browser attaches event handlers to server-rendered HTML, and until then the page can look ready without responding.
  • Choose per route: a marketing page, a product listing and a logged-in dashboard often need different strategies.
  • If you’ve used React Server Components or streaming, explain the benefit plainly: less JavaScript sent to the browser and content shown sooner.
Sample answer

I decide per page, based on how often the content changes, whether it needs to be found in search, and how interactive it is. Static generation builds the HTML ahead of time, so it can be served from a CDN very quickly. It suits marketing pages, documentation and articles, with a rebuild or revalidation when content changes. Server-side rendering builds the HTML on each request, which suits pages that are personalised or change constantly but still need fast first content and good SEO, like a product listing. The cost is server work and hydration: the page can look ready before its JavaScript has taken over. Client-side rendering sends a light HTML shell and builds the page in the browser, which is fine for a logged-in dashboard where search doesn’t matter. Most modern frameworks let me mix these, and server components cut how much JavaScript reaches the browser.

A list with thousands of rows becomes sluggish when users type in a filter box. How would you investigate?

What they’re checking: This tests whether you measure before optimising, and whether you know the main techniques for keeping a page responsive.

  • Profile first, with the browser’s performance panel or React’s profiler, to see whether the time goes into filtering, rendering or layout.
  • Render only what’s visible with list virtualisation, and avoid re-rendering rows that haven’t changed.
  • Keep typing responsive by treating the list update as non-urgent, with startTransition or useDeferredValue, or by debouncing the filter.
  • Move genuinely heavy computation to a web worker, then measure again to confirm the fix worked.

Behavioural and collaboration questions

Frontend work sits between design, product and backend, so expect questions about how you collaborate as well as what you built. Use real stories; the STAR method keeps them focused.

Tell me about a tricky UI bug you tracked down and fixed.

What they’re checking: They want to see a methodical debugging process across browsers and devices, and what you did to stop the bug coming back.

  • Choose a bug with an interesting cause: a race between requests, a time-zone issue, a browser-specific layout problem or a stale closure.
  • Describe how you reproduced it reliably before fixing it; that’s often the hardest part.
  • End with the prevention: a test, a lint rule, a shared utility or a note in the component’s documentation.
Sample answer

At [Company], users reported that [the symptom — for example, search results sometimes showed data for an older query]. I couldn’t reproduce it at first, so I [how you reproduced it — for example, slowed the network in the browser’s developer tools and typed quickly]. That revealed the cause: [the root cause — for example, responses arriving out of order, so a slow earlier request overwrote the latest results]. I fixed it by [your fix — for example, cancelling the previous request and ignoring stale responses], then checked it on [the browsers and devices you tested]. To stop it coming back, I [the prevention — for example, added a test that simulates slow responses and moved the logic into a shared hook the team now uses]. Since then, I test on a slow network as a normal part of building anything that fetches data.

How do you work with designers, especially when a design is hard to build or missing details?

What they’re checking: Good frontend work depends on a healthy relationship with design. Interviewers look for early involvement, respect for the design intent and honest conversations about trade-offs.

  • Ask about the states designs often miss: loading, empty, error, very long text, small screens and keyboard focus.
  • When something is expensive to build, offer an alternative that keeps the intent, rather than just saying no.
  • Mention shared foundations, such as design tokens and a component library, that keep design and code consistent.
Sample answer

I try to get involved before designs are final. In reviews, I walk through the states that are easy to miss: loading, empty and error states, very long names, small screens and what keyboard focus looks like. On [project], the design included [a hard-to-build element — for example, a custom animated dropdown] that would have taken [rough effort] and had accessibility problems. Rather than push back in a comment, I built a quick prototype of [your alternative — for example, a native select with custom styling] and showed the designer both versions side by side. We agreed on [the outcome], which kept the look they wanted and [shipped sooner, or with fewer issues]. I also share work in progress early, so designers see it in a real browser and on a phone, not only in the design file.

How do you test frontend code?

What they’re checking: They want a balanced strategy that catches real regressions without slowing the team down with brittle tests.

  • Unit-test logic such as formatting, validation and state reducers; these tests are fast and stable.
  • Test components the way a user would: find elements by role or label, interact with them and check what appears, rather than checking internal state.
  • Keep a small number of end-to-end tests for critical journeys, such as sign-up and checkout, and run them in CI on every change.
  • Add automated accessibility checks and visual regression tests where they help, and be clear about what they can’t catch.

Questions to ask the interviewer

  • How do designers and engineers work together here, and at what stage do engineers see new designs?
  • Is there a shared component library or design system, and who looks after it?
  • How do you track frontend performance in production, and who acts on it?
  • Which browsers and devices do your users mainly use, and what does the team support?
  • How is accessibility handled in code review, testing and the definition of done?
  • What would you expect a new frontend developer to have shipped in the first three months?

Common mistakes

  • Answering platform questions with framework details; explain what the browser does first, then how your framework builds on it.
  • Building everything from divs in a live UI task; use buttons, labels and headings, because interviewers notice and it saves accessibility work later.
  • Skipping loading, empty and error states in a coding exercise; mention them out loud even if there isn’t time to build them all.
  • Claiming performance improvements without saying how you measured them; name the metric, how you measured it and the before-and-after results from your own work.
  • Describing First Input Delay as a current Core Web Vital; INP replaced it in 2024, and outdated answers suggest you haven’t kept up.
  • Reaching for a global state library or memoisation everywhere; start simple and explain what problem would make you add more.

The day before

  • Build one component from scratch, such as accessible tabs, a modal or an autocomplete, explaining your decisions out loud as you go.
  • Predict the output of a few snippets that mix setTimeout, promises and async/await, then run them to check.
  • Check a project you’ve built with a performance tool and with the keyboard alone, and note one thing you would improve.
  • Prepare three stories: a UI bug you fixed, a design problem you worked through with a designer, and a performance or accessibility improvement.
  • Use the company’s product on a phone and a laptop, and note one thing you liked and one question you’d ask about it.
  • Test your camera, microphone, internet connection and any shared editor link you’ve been sent.
Practise these questions out loud

Lucimeet’s AI interviewer asks you the questions, listens to your answers, asks follow-ups and scores each one — then shows a better way to say it. Your first interview is free.