Web developer interview questions and how to answer them
Web developer interview questions span the whole path of a website: semantic HTML, CSS layout, JavaScript in the browser, HTTP and how pages load, forms and security, performance, and getting a site deployed. Expect a mix of knowledge questions, a practical task such as building a small page or fixing a bug, and a walk-through of sites you have built. Agencies and small teams often care as much about CMS work, hosting and client changes as about frameworks.
By Evin JohnPublished 8 min read
What web developer roles usually involve
"Web developer" covers a wide range. At an agency it often means building marketing sites and online stores from designs, working in a CMS such as WordPress, Shopify or a headless system, and handling hosting and client edits. In a company it can mean maintaining the main website, landing pages and internal tools. Some roles lean to the browser and overlap with a frontend developer; others include server code, databases and APIs, closer to a backend developer. Read the stack in the posting and weight your preparation to match.
Across all versions, interviewers look for solid fundamentals, clean and accessible markup, layouts that work on every screen size, care about speed and security, and the habit of shipping: version control, testing in real browsers and deploying without drama. You will often build from a UI designer's files, so questions about turning a design into code are common too.
How the hiring process often looks
- ScreenStack, projects, portfolio links and GitHub. Some companies add a short online quiz on HTML, CSS and JavaScript.
- Technical interviewKnowledge questions on the web platform, plus reading and explaining a piece of code.
- Practical taskBuild a responsive component from a mockup, fetch and display data from an API, or fix bugs in a small repository. Live or take-home.
- Project and team roundWalk through a site you built, how you worked with designers and clients, and how you handled deadlines.
HTML and accessibility questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| Why does semantic HTML matter? | Markup quality | Screen readers, search engines and maintainers understand structure from elements like header, nav, main, article and button |
| When would you use a button and when a link? | Correct elements | Links navigate to a URL; buttons perform actions. A clickable div breaks keyboard and screen reader use |
| How do you make a form accessible? | Forms | Labels tied to inputs, clear error messages linked to fields, logical tab order and correct input types |
| What does the alt attribute do, and when is it empty? | Images | Describes the image's purpose; empty for purely decorative images so assistive tech skips them |
| What goes in the head of a page? | Document basics | Charset, viewport meta, title, description, canonical link, stylesheets and social preview tags |
CSS and layout questions
- When do you use Flexbox and when Grid? Flexbox for one-dimensional rows or columns, Grid for two-dimensional layouts. Many layouts use Grid for the page and Flexbox inside components.
- Explain the box model and box-sizing. Content, padding, border and margin; border-box includes padding and border in the declared width, which makes sizing predictable.
- How does specificity work? Inline styles beat IDs, IDs beat classes and attributes, which beat elements. Explain why you keep specificity low and avoid important flags.
- How do you build a responsive layout? Mobile-first styles, fluid widths, media or container queries at points where the content breaks, and responsive images.
- What is the difference between position relative, absolute, fixed and sticky? Describe what each is positioned against and give one use case for each.
- How would you center an element both ways? Grid with place-items center, or Flexbox with both alignment properties. Mention that the parent needs a height.
- How do you organize CSS on a larger site? A naming method such as BEM, utility classes, CSS modules or a framework like Tailwind, with shared design tokens as custom properties.
JavaScript and browser questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| What is the difference between let, const and var? | Scope | Block scope for let and const, function scope and hoisting for var, and const preventing reassignment but not mutation |
| What is event delegation? | DOM events | One listener on a parent handles events from many children through bubbling, useful for dynamic lists |
| How do promises and async/await work? | Asynchronous code | Async functions return promises, await pauses inside the function, and errors need try/catch or a catch handler |
| What happens when you type a URL and press Enter? | Whole-stack picture | DNS lookup, TCP and TLS connection, HTTP request, server response, parsing HTML, loading CSS and scripts, rendering |
| Where would you store data in the browser? | Storage options | Cookies for server-read values, localStorage for small non-sensitive data, IndexedDB for larger data, and never secrets in client storage |
| What is the difference between == and ===? | Type coercion | Loose equality converts types first; strict equality does not, which is why most codebases use strict |
A common live task is to load data from an API and show it, with loading and error handling. Interviewers watch whether you check the response status, since fetch does not reject on HTTP errors.
async function loadPosts(listEl) {
listEl.textContent = "Loading...";
try {
const res = await fetch("/api/posts");
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
const posts = await res.json();
listEl.replaceChildren(
...posts.map((p) => {
const li = document.createElement("li");
li.textContent = p.title; // textContent, not innerHTML, avoids XSS
return li;
})
);
} catch (err) {
listEl.textContent = "Could not load posts. Please try again.";
console.error(err);
}
}HTTP, security and performance questions
- What do the main HTTP methods and status codes mean? GET reads, POST creates, PUT and PATCH update, DELETE removes. Know 200, 201, 301, 304, 400, 401, 403, 404 and 500.
- What is CORS and why do you see CORS errors? The browser blocks cross-origin requests unless the server allows the origin through response headers. The fix belongs on the server.
- How do you prevent XSS? Escape output, avoid inserting untrusted HTML, use a content security policy, and rely on frameworks that escape by default.
- What is CSRF and how is it prevented? A forged request using the victim's cookies. Prevent it with tokens, SameSite cookies and checking the origin.
- How do you prevent SQL injection? Parameterized queries or an ORM, never building SQL from user input by string concatenation.
- How would you speed up a slow page? Measure first with Lighthouse or the browser's performance tools, then compress and size images, cut unused JavaScript, defer non-critical scripts, cache static files and use a CDN.
- What are Core Web Vitals? Google's user experience metrics for loading (LCP), responsiveness (INP) and visual stability (CLS). Explain one fix for each.
- How does browser caching work? Cache-Control headers, ETags for revalidation, and file names with content hashes so you can cache assets for a long time.
CMS, deployment and workflow questions
- How have you built sites on a CMS? Custom themes or templates, content models that editors understand, and keeping plugins few and updated.
- How do you deploy a website? Git-based deploys to a host or a static hosting service, environment variables for secrets, and a way to roll back.
- Walk me through pointing a domain to a new host. DNS records such as A or CNAME, waiting for propagation, and setting up HTTPS certificates.
- How do you test across browsers and devices? Real devices for key flows, browser developer tools for responsive checks, and automated tests where the project has them.
- How do you use Git on a team? Feature branches, small commits with clear messages, pull requests with review, and resolving conflicts without overwriting others' work.
- A client wants a change the day before launch. What do you do? Assess the risk and effort, explain the options, and agree whether it goes in now or right after launch.
Fictional example
- I maintained the website for a furniture retailer, and the product pages felt slow on phones. I ran Lighthouse and the browser's performance panel and found two causes: hero photos uploaded at full camera size, and a chat widget script loading before the page content. I set up responsive images with srcset in modern formats, lazy-loaded images below the fold, and loaded the chat script only after the page became interactive. I checked the result on a mid-range phone over a throttled connection. Page load felt clearly faster, the largest image appeared much sooner in the reports, and the marketing team saw fewer people leave product pages early. I now add an image size check to every content upload guide I write.
A two-week plan
- Days 1 to 3: rebuild a landing page section from a screenshot using semantic HTML and Grid or Flexbox, mobile first, without a framework.
- Days 4 to 6: practice JavaScript basics: DOM manipulation, events, fetch with error handling, and array methods. Explain each solution aloud.
- Days 7 and 8: review HTTP, caching, CORS and the three common security attacks until you can explain each in under a minute.
- Days 9 and 10: run Lighthouse on a site you built, fix the top issues and note the before and after.
- Days 11 and 12: prepare a walk-through of your best project, including hosting and one problem you solved.
- Days 13 and 14: practice behavioral stories on client changes and deadlines with the behavioral question guide, and read the employer's site source to see their stack.
Narrating code while writing it takes practice of its own. Natively, an AI interview assistant for Mac and Windows, can transcribe a mock technical round on your computer and keep the transcript and notes, so you can see where your explanation of a layout or a fetch call trailed off. In practice it can read a coding task from a screenshot and suggest an approach, and help with code when you are stuck; with Pro or the free trial it can also weigh the résumé and job description you added.
Questions people ask
What questions are asked in a web developer interview?
Expect questions on semantic HTML and accessibility, CSS layout with Flexbox and Grid, JavaScript and the DOM, HTTP, caching and CORS, security issues such as XSS and SQL injection, performance, and how you deploy and maintain sites.
What is the practical test in a web developer interview?
Common tasks are building a responsive section from a mockup, fetching and displaying data from an API with error handling, or fixing bugs in a small repository, either live or as a take-home.
How do I prepare for a web developer interview as a fresher?
Build two or three small sites from scratch, practice explaining HTML, CSS and JavaScript fundamentals aloud, learn HTTP basics and common attacks, and be ready to walk through how you deployed one project.
What is the difference between a web developer and a frontend developer?
Frontend developer roles focus on the browser and usually a framework such as React. Web developer roles are often broader and can include CMS work, server code, hosting, DNS and client changes.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
