Web Development Interview Questions & Answers
All 200 unique questions in one place — 60 easy, 94 medium, 46 hard — grouped by topic.
Practise by topic
Practise the way your interview works
What is the difference between block-level and inline elements?
Show answer
What does the DOCTYPE declaration do in an HTML page?
Show answer
What is the difference between id and class attributes?
Show answer
What is the difference between GET and POST methods in an HTML form?
Show answer
Write an accessible login form with proper labels.
Show answer
Write the basic SEO meta tags for a course landing page.
Show answer
Why should external links opened with target='_blank' use rel='noopener'?
Show answer
Tell me about a website you built from scratch.
Show answer
When should you use section, article or div?
Show answer
What are data-* attributes and when do you use them?
Show answer
Explain the difference between async and defer on a script tag.
Show answer
Why is the meta viewport tag needed for mobile pages?
Show answer
How do srcset and sizes help with responsive images?
Show answer
What is ARIA and when should you use it?
Show answer
Show HTML5 built-in validation for a registration form.
Show answer
Use the picture element to serve WebP or AVIF with a JPEG fallback.
Show answer
How do you lazy load images and iframes natively?
Show answer
An accessibility audit gives your site a low score. What would you fix first?
Show answer
A client wants better Google rankings. What HTML-level changes would you make?
Show answer
Product images look blurry on high-resolution phone screens. How do you fix it?
Show answer
How do you keep yourself updated with changes in web standards?
Show answer
Explain the critical rendering path and how HTML structure affects it.
Show answer
A contact form is receiving hundreds of spam submissions daily. What do you do?
Show answer
Lighthouse shows a poor Largest Contentful Paint caused by the hero image. What steps do you take?
Show answer
Explain the CSS box model.
Show answer
How does CSS specificity work?
Show answer
What is the difference between pseudo-classes and pseudo-elements?
Show answer
Center a div horizontally and vertically using Flexbox and Grid.
Show answer
Write CSS for a simple responsive navigation that becomes a column on mobile.
Show answer
Uploaded images overflow their containers and break the layout. What is the fix?
Show answer
How do you handle a very tight deadline for a landing page?
Show answer
Explain the values of the CSS position property.
Show answer
When would you choose Flexbox and when CSS Grid?
Show answer
What is the difference between px, em and rem units?
Show answer
What are CSS custom properties and how are they different from Sass variables?
Show answer
What does mobile-first CSS mean?
Show answer
What is margin collapsing?
Show answer
Create a responsive card grid that needs no media queries.
Show answer
Implement dark mode using CSS custom properties.
Show answer
Make a header that sticks to the top while scrolling.
Show answer
Your page shows a horizontal scrollbar on mobile. How do you find and fix the cause?
Show answer
A modal appears behind the header even with z-index 9999. What is wrong?
Show answer
Tell me about a time you disagreed with a designer about a layout.
Show answer
How do you test a website for cross-browser compatibility?
Show answer
What is a stacking context and why does z-index sometimes not work?
Show answer
What are container queries and how do they differ from media queries?
Show answer
Compare BEM and utility-first approaches to CSS architecture.
Show answer
Use clamp() to create fluid typography.
Show answer
The site's main CSS file is 400 KB and first paint is slow. How do you optimise it?
Show answer
A third-party widget's CSS keeps overriding your button styles. How do you handle it?
Show answer
Your page has a high Cumulative Layout Shift because of fonts and ads. How do you reduce it?
Show answer
What is the difference between var, let and const?
Show answer
What is hoisting in JavaScript?
Show answer
What is the difference between == and ===?
Show answer
What are truthy and falsy values?
Show answer
What is the difference between null and undefined?
Show answer
What are the spread and rest operators?
Show answer
Remove duplicates from an array of numbers and from an array of objects.
Show answer
Use map, filter and reduce to calculate the total price of in-stock items.
Show answer
Your code throws 'Unexpected token < in JSON' after an API call. What does it mean?
Show answer
How do you learn a new JavaScript concept you do not understand?
Show answer
Explain closures with an example.
Show answer
How is the value of this decided in JavaScript?
Show answer
What is the difference between Promises and async/await?
Show answer
How do arrow functions differ from regular functions?
Show answer
What is the difference between a shallow copy and a deep copy?
Show answer
Write a debounce function and explain where it is used.
Show answer
Fetch data from an API with async/await and handle errors properly.
Show answer
Write a function that groups an array of students by city.
Show answer
An API is being called twice when the page loads. How do you debug it?
Show answer
A cart total shows 0.30000000000000004 instead of 0.3. Why, and how do you fix it?
Show answer
Describe a bug you found in production and how you handled it.
Show answer
Explain the JavaScript event loop.
Show answer
Explain prototypal inheritance in JavaScript.
Show answer
What are iterators and generators in JavaScript?
Show answer
A dashboard page becomes slower the longer it stays open. What could cause it?
Show answer
What is the DOM?
Show answer
What is the difference between preventDefault and stopPropagation?
Show answer
What is the difference between DOMContentLoaded and the load event?
Show answer
How is querySelector different from getElementById and getElementsByClassName?
Show answer
What is AJAX and how is it done today?
Show answer
Build a todo list where items can be added and deleted using event delegation.
Show answer
Click handlers do not work on buttons added after the page loads. Why?
Show answer
How would you explain a technical problem to a non-technical client?
Show answer
Explain event bubbling and capturing.
Show answer
What is event delegation and why is it useful?
Show answer
What is the difference between innerHTML, textContent and innerText?
Show answer
Compare localStorage, sessionStorage and cookies.
Show answer
What are custom events and when would you use them?
Show answer
Validate a signup form with JavaScript before submission.
Show answer
Create a dark mode toggle that remembers the user's choice.
Show answer
Fetch a list of products and render them safely into the page.
Show answer
Open and close an accessible modal using the native dialog element.
Show answer
A comment section displays user input using innerHTML. What is the risk and fix?
Show answer
Users lose a long form's data when they accidentally refresh. How do you solve it?
Show answer
Describe a time you improved the performance of a web page.
Show answer
What is the difference between reflow and repaint?
Show answer
Implement infinite scroll using IntersectionObserver.
Show answer
The page stutters while scrolling because of a scroll event handler. How do you fix it?
Show answer
Users click the Pay button twice and get charged twice. How do you prevent it?
Show answer
Rendering a table with 5,000 rows freezes the browser. What are your options?
Show answer
What is PHP and how does a PHP page get processed?
Show answer
What is the difference between echo and print in PHP?
Show answer
What is the difference between sessions and cookies in PHP?
Show answer
Explain include, require, include_once and require_once.
Show answer
What are PHP superglobals?
Show answer
Insert a record into MySQL securely using PDO.
Show answer
Use the PHP 8 match expression instead of a switch.
Show answer
A PHP page shows a blank white screen. How do you debug it?
Show answer
You see 'Headers already sent' warnings. What causes it and how do you fix it?
Show answer
Why did you choose PHP for backend development?
Show answer
How did string and number comparison with == change in PHP 8?
Show answer
Should you use PDO or mysqli to connect to MySQL?
Show answer
What is the difference between an abstract class and an interface in PHP?
Show answer
What are traits in PHP?
Show answer
What is Composer and how does PSR-4 autoloading work?
Show answer
Name important features added in PHP 8.x.
Show answer
How should passwords be stored in PHP?
Show answer
What is MVC and how does Laravel follow it?
Show answer
Write a PHP login script using password_verify and sessions.
Show answer
Build a simple PHP endpoint that returns JSON.
Show answer
Users get logged out immediately after login when redirected. What could be wrong?
Show answer
Tell me about a time you had to work with messy legacy code.
Show answer
What does declare(strict_types=1) do?
Show answer
Write secure PHP code to handle an image upload.
Show answer
A PHP page takes 8 seconds to load. How do you find the bottleneck?
Show answer
You must upgrade an old project from PHP 7.4 to PHP 8.3. How do you plan it?
Show answer
What is the difference between a primary key and a foreign key?
Show answer
Explain INNER JOIN, LEFT JOIN and RIGHT JOIN.
Show answer
What is the difference between WHERE and HAVING?
Show answer
What is the difference between DELETE, TRUNCATE and DROP?
Show answer
When should you use CHAR, VARCHAR and TEXT?
Show answer
What is the difference between UNION and UNION ALL?
Show answer
Write a query to find the second highest salary.
Show answer
How do you make sure you do not break production data while working?
Show answer
Explain database normalization up to third normal form.
Show answer
What is the difference between InnoDB and MyISAM?
Show answer
What are transactions and ACID properties?
Show answer
Write a query to find duplicate email addresses in a users table.
Show answer
Create students, courses and enrollments tables with proper keys.
Show answer
Show monthly revenue for the current year from an orders table.
Show answer
How do you back up and restore a MySQL database from the command line?
Show answer
The database server is overloaded by read traffic. What architecture changes would you suggest?
Show answer
Tell me about a database design you are proud of.
Show answer
How do indexes work and when can they hurt performance?
Show answer
How do you read the output of EXPLAIN in MySQL?
Show answer
Explain transaction isolation levels in MySQL.
Show answer
Find the top 3 highest-paid employees in each department.
Show answer
A search query on a 2 million row products table takes 6 seconds. How do you speed it up?
Show answer
Your application logs show frequent deadlock errors. What do you do?
Show answer
Pagination becomes very slow on later pages. Why, and how do you fix it?
Show answer
Someone accidentally ran DELETE without a WHERE clause on production. How do you recover?
Show answer
What is SQL injection and how do prepared statements stop it?
Show answer
Escape user data correctly when printing it in PHP templates.
Show answer
After moving to HTTPS, browsers show mixed content warnings. How do you fix them?
Show answer
What is a mistake you made in web development and what did you learn?
Show answer
Explain the types of cross-site scripting (XSS).
Show answer
What is CSRF and how do you prevent it?
Show answer
What is CORS and why does the browser block some API calls?
Show answer
Add CSRF protection to a plain PHP form.
Show answer
Configure secure session cookie settings in PHP.
Show answer
Limit failed login attempts to stop brute-force attacks.
Show answer
Validate and sanitise different types of input in PHP.
Show answer
A client's WordPress site has been hacked and shows spam links. What steps do you take?
Show answer
Database credentials were accidentally pushed to a public GitHub repository. What now?
Show answer
Your frontend on one domain gets a CORS error calling your API on another. How do you resolve it?
Show answer
Tell me about a time you found a security issue in someone else's code.
Show answer
How do you handle pressure to skip security work to meet a deadline?
Show answer
Which HTTP security headers should every website send?
Show answer
Add security headers through Nginx configuration.
Show answer
A user can view another user's invoice by changing the id in the URL. What is this and how do you fix it?
Show answer
An attacker uploaded a PHP web shell through the profile picture feature. How did it happen and how do you prevent it?
Show answer
Design a secure forgot-password flow.
Show answer
Before launching a new web application, how would you run a basic security review?
Show answer
Users report being redirected to a gambling site from your pages. What do you check?
Show answer
Describe how you would respond if your website suffered a data breach.
Show answer
Compare shared hosting, VPS and cloud hosting.
Show answer
Explain the common DNS record types.
Show answer
You changed DNS to a new server but some users still see the old site. Why?
Show answer
Why do you want to work as a web developer?
Show answer
What is a CDN and how does it improve a website?
Show answer
What are the differences between Apache and Nginx?
Show answer
How do SSL/TLS certificates work, and what is Let's Encrypt?
Show answer
Write .htaccess rules to force HTTPS and the non-www domain.
Show answer
Deploy a PHP project to a VPS using Git and SSH.
Show answer
Schedule a nightly database backup with cron.
Show answer
Your site suddenly shows 502 Bad Gateway. How do you troubleshoot it?
Show answer
The server's disk is full and the site has stopped saving data. What do you do?
Show answer
Emails sent from your website contact form land in spam. How do you fix it?
Show answer
Time to first byte is over 2 seconds even for simple pages. What do you check?
Show answer
Tell me about a time a website went down and how you handled it.
Show answer
A client insists on a major deployment on Friday evening. How do you respond?
Show answer
Write an Nginx server block for a PHP application using PHP-FPM.
Show answer
Create a GitHub Actions workflow that deploys on every push to main.
Show answer
A results website expects ten times normal traffic on announcement day. How do you prepare?
Show answer
How would you deploy updates without any downtime?
Show answer
A client wants to move a growing site from shared hosting to a VPS. How do you plan the migration?
Show answer
How do you manage configuration and secrets across local, staging and production?
Show answer
How have you helped a junior developer learn deployment?
Show answer
Frequently asked questions
What jobs can I get after learning web development?
You can apply for roles such as Junior Web Developer, Front-End Developer, PHP Developer, WordPress Developer and Full Stack Web Developer. IT services companies, digital agencies, startups and e-commerce businesses all hire for these roles. With experience you can move into lead developer, solutions architect or web security roles. A strong portfolio of live projects matters as much as your degree when recruiters shortlist web development candidates.
Who is eligible to learn web development?
Anyone comfortable with basic computer use can start, including school pass-outs, BCA, B.Tech, B.Sc and BCom graduates, and working professionals switching careers. No prior coding knowledge is required because the course starts from HTML basics. Logical thinking and regular practice are more important than your academic stream. Many successful developers in India come from non-computer-science backgrounds and learned through structured courses and projects.
How long does it take to learn web development?
With two to three hours of daily practice, most learners become job-ready for junior roles in about four months, covering HTML, CSS, JavaScript, PHP, MySQL and deployment. Becoming comfortable with frameworks like Laravel and handling production issues takes another six to twelve months of real work. Consistency is key: building small projects every week speeds up learning far more than only watching tutorials.
Do I need a certificate to get a web developer job?
A certificate helps show that you completed structured training, and some companies use it during screening, but hiring decisions mostly depend on your skills and projects. Recruiters look at your GitHub profile, live websites and how well you answer technical questions. Combine your course certificate with two or three deployed projects, clean code and a clear resume to stand out in interviews.
Is PHP still worth learning in 2026?
Yes. PHP powers WordPress and a large share of websites worldwide, and Laravel remains a popular framework for startups and agencies in India. Many existing business applications run on PHP and need developers to maintain and extend them. Learning PHP also teaches server-side fundamentals like requests, sessions and databases, which transfer easily to Node.js, Python or Java later in your career.
What projects should I build for a web development portfolio?
Build projects that show the full stack: a responsive portfolio site, a JavaScript app that uses a public API, a PHP and MySQL application with login and CRUD features, and a deployed e-commerce or booking mini project with HTTPS. Write clear README files with screenshots and live links. Interviewers often ask how you built each feature, so choose projects you can explain confidently.