10 Web Development Interview Q&A
1. What is the use of the <link> tag in HTML?
A: The <link> tag connects the HTML to external resources, mostly used for:
- Adding CSS files
- Setting favicons
Example:
<link rel="stylesheet" href="style.css">
2. What is the difference between block and inline elements?
A: Block elements take the full width (like <div>, <p>, <section>)
Inline elements take only required width (like <span>, <a>, <strong>)
3. What is a Semantic Tag in HTML5?
A: Semantic tags clearly define the meaning of content, making it more readable for humans and search engines.
Examples:
- <header>, <nav>, <main>, <footer>, <article>, <aside>
4. How to center a div using CSS?
A: Horizontally + Vertically centered using Flexbox:
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
5. What is the use of z-index in CSS?
A: z-index controls the stacking order of elements. Higher z-index appears above lower ones.
.box {
position: absolute;
z-index: 10;
}
6. What is JavaScript used for in web development?
A: JavaScript is used to make web pages interactive and dynamic — like:
- Validating forms
- Creating sliders, modals, dropdowns
- Fetching data using APIs
7. What is the difference between null and undefined in JavaScript?
A: `undefined`: A variable declared but not assigned
`null`: A variable is assigned empty value manually
let a; // undefined
let b = null; // null
8. What is the use of the this keyword in JavaScript?
A: `this` refers to the current context/object where the code is being executed.
const person = {
name: "Mohit",
greet: function () {
console.log("Hello " + this.name);
}
};
9. What is Tailwind CSS?
A: Tailwind CSS is a utility-first CSS framework where you use small classes directly in HTML to design.
Example:
<div class="bg-blue-500 text-white p-4 rounded-lg">
Welcome to MK_Coder!
</div>
10. What are Cookies in web development?
A: Cookies are small pieces of data stored on the user's browser to remember information like login, cart, preferences, etc.
document.cookie = "username=Mohit; expires=Sun, 25 Aug 2025 12:00:00 UTC";
Bonus Practice Tip:
- Use Codepen.io or JSFiddle to practice HTML/CSS/JS live.
- Start building your portfolio website and try to add each concept you learn.
Web Development Interview Q&A - Part 2
1. What is the use of the <link> tag in HTML?
A: The <link> tag connects the HTML to external resources, mostly used for:
- Adding CSS files
- Setting favicons
Example:
<link rel="stylesheet" href="style.css">
2. What is the difference between block and inline elements?
A: Block elements take the full width (like <div>, <p>, <section>)
Inline elements take only required width (like <span>, <a>, <strong>)
3. What is a Semantic Tag in HTML5?
A: Semantic tags clearly define the meaning of content, making it more readable for humans and search engines.
Examples:
- <header>, <nav>, <main>, <footer>, <article>, <aside>
4. How to center a div using CSS?
A: Horizontally + Vertically centered using Flexbox:
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
5. What is the use of z-index in CSS?
A: z-index controls the stacking order of elements. Higher z-index appears above lower ones.
.box {
position: absolute;
z-index: 10;
}
6. What is JavaScript used for in web development?
A: JavaScript is used to make web pages interactive and dynamic — like:
- Validating forms
- Creating sliders, modals, dropdowns
- Fetching data using APIs
7. What is the difference between null and undefined in JavaScript?
A: `undefined`: A variable declared but not assigned
`null`: A variable is assigned empty value manually
let a; // undefined
let b = null; // null
8. What is the use of the this keyword in JavaScript?
A: `this` refers to the current context/object where the code is being executed.
const person = {
name: "Mohit",
greet: function () {
console.log("Hello " + this.name);
}
};
9. What is Tailwind CSS?
A: Tailwind CSS is a utility-first CSS framework where you use small classes directly in HTML to design.
Example:
<div class="bg-blue-500 text-white p-4 rounded-lg">
Welcome to MK_Coder!
</div>
10. What are Cookies in web development?
A: Cookies are small pieces of data stored on the user's browser to remember information like login, cart, preferences, etc.
document.cookie = "username=Mohit; expires=Sun, 25 Aug 2025 12:00:00 UTC";
Bonus Practice Tip:
- Use Codepen.io or JSFiddle to practice HTML/CSS/JS live.
- Start building your portfolio website and try to add each concept you learn.
Web Development Interview Q&A - Part 3
1. What is the use of the <link> tag in HTML?
A: The <link> tag connects the HTML to external resources, mostly used for:
- Adding CSS files
- Setting favicons
Example:
<link rel="stylesheet" href="style.css">
2. What is the difference between block and inline elements?
A: Block elements take the full width (like <div>, <p>, <section>)
Inline elements take only required width (like <span>, <a>, <strong>)
3. What is a Semantic Tag in HTML5?
A: Semantic tags clearly define the meaning of content, making it more readable for humans and search engines.
Examples:
- <header>, <nav>, <main>, <footer>, <article>, <aside>
4. How to center a div using CSS?
A: Horizontally + Vertically centered using Flexbox:
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
5. What is the use of z-index in CSS?
A: z-index controls the stacking order of elements. Higher z-index appears above lower ones.
.box {
position: absolute;
z-index: 10;
}
6. What is JavaScript used for in web development?
A: JavaScript is used to make web pages interactive and dynamic — like:
- Validating forms
- Creating sliders, modals, dropdowns
- Fetching data using APIs
7. What is the difference between null and undefined in JavaScript?
A: `undefined`: A variable declared but not assigned
`null`: A variable is assigned empty value manually
let a; // undefined
let b = null; // null
8. What is the use of the this keyword in JavaScript?
A: `this` refers to the current context/object where the code is being executed.
const person = {
name: "Mohit",
greet: function () {
console.log("Hello " + this.name);
}
};
9. What is Tailwind CSS?
A: Tailwind CSS is a utility-first CSS framework where you use small classes directly in HTML to design.
Example:
<div class="bg-blue-500 text-white p-4 rounded-lg">
Welcome to MK_Coder!
</div>
10. What are Cookies in web development?
A: Cookies are small pieces of data stored on the user's browser to remember information like login, cart, preferences, etc.
document.cookie = "username=Mohit; expires=Sun, 25 Aug 2025 12:00:00 UTC";
10 Web Development Interview Q&A – Part 4
1. Explain the CSS Box Model.
A: The CSS Box Model describes how HTML elements are rendered as boxes, comprising content, padding, border, and margin. Each part adds to the total space an element takes on the page.
- **Content:** The actual content of the element (text, images, etc.).
- **Padding:** Space between the content and the border.
- **Border:** A line around the padding and content.
- **Margin:** Space outside the border, separating the element from other elements.
2. What is the purpose of the `DOCTYPE` declaration in HTML?
A: The `DOCTYPE` declaration tells the web browser which version of HTML the page is written in. This helps the browser render the page correctly according to the specified HTML standard. For HTML5, it's a simple ` `.
3. What is the difference between `localStorage` and `sessionStorage`?
A: Both `localStorage` and `sessionStorage` are web storage objects that allow JavaScript sites to save key-value pairs in the browser.
- **`localStorage`:** Stores data with no expiration date; data persists even after the browser is closed and reopened.
- **`sessionStorage`:** Stores data only for the duration of the browser session; data is cleared when the browser tab or window is closed.
4. How do you include JavaScript in an HTML file?
A: JavaScript can be included in an HTML file in three main ways:
- **Inline:** Directly within HTML tags using the `on` event attributes (e.g., `
- **Internal:** Within ` ` tag. This is the preferred method for larger scripts.
5. What are CSS preprocessors, and why use them?
A: CSS preprocessors (like Sass, Less, Stylus) are scripting languages that extend CSS with features like variables, nesting, mixins, and functions that are not available in standard CSS. They make CSS more maintainable, reusable, and dynamic. The preprocessor code is then compiled into regular CSS that browsers can understand.
6. Explain the concept of "Mobile-First" design.
A: Mobile-First design is a responsive web design strategy where you start designing and developing for the smallest screen sizes (mobile devices) first, and then progressively enhance the design for larger screens (tablets, desktops). This approach ensures optimal performance and user experience on mobile, and then adds complexity for larger views.
7. What is the DOM (Document Object Model)?
A: The DOM is a programming interface for web documents. It represents the page structure as a tree of objects, where each HTML element is a node. JavaScript can use the DOM to access, manipulate, and modify the content, structure, and style of a web page dynamically.
8. What is the difference between `==` and `===` in JavaScript?
A: Both are comparison operators in JavaScript:
- **`==` (Loose Equality):** Compares values after converting them to a common type (type coercion). For example, `5 == '5'` is true.
- **`===` (Strict Equality):** Compares values without type conversion. It checks both the value and the data type. For example, `5 === '5'` is false, but `5 === 5` is true. It's generally recommended for safer comparisons.
9. What is a CSS Framework? Give examples.
A: A CSS framework is a library of pre-written CSS code that provides ready-to-use styles, components, and utilities to speed up web development. They offer a structured way to build responsive and consistent user interfaces.
Examples: Bootstrap, Tailwind CSS, Bulma, Foundation.
10. What is version control, and why is Git important?
A: Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. It's essential for collaborative development and tracking changes.
**Git** is a widely used distributed version control system. It allows multiple developers to work on the same project simultaneously without overwriting each other's changes, track history, revert to previous versions, and manage different branches of a project.
Bonus Practice Tip:
- Use Codepen.io or JSFiddle to practice HTML/CSS/JS live.
- Start building your portfolio website and try to add each concept you learn.
Web Development Interview Q&A - Part 5
1. What is the use of the <link> tag in HTML?
A: The <link> tag connects the HTML to external resources, mostly used for:
- Adding CSS files
- Setting favicons
Example:
<link rel="stylesheet" href="style.css">
2. What is the difference between block and inline elements?
A: Block elements take the full width (like <div>, <p>, <section>)
Inline elements take only required width (like <span>, <a>, <strong>)
3. What is a Semantic Tag in HTML5?
A: Semantic tags clearly define the meaning of content, making it more readable for humans and search engines.
Examples:
- <header>, <nav>, <main>, <footer>, <article>, <aside>
4. How to center a div using CSS?
A: Horizontally + Vertically centered using Flexbox:
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
5. What is the use of z-index in CSS?
A: z-index controls the stacking order of elements. Higher z-index appears above lower ones.
.box {
position: absolute;
z-index: 10;
}
6. What is JavaScript used for in web development?
A: JavaScript is used to make web pages interactive and dynamic — like:
- Validating forms
- Creating sliders, modals, dropdowns
- Fetching data using APIs
7. What is the difference between null and undefined in JavaScript?
A: `undefined`: A variable declared but not assigned
`null`: A variable is assigned empty value manually
let a; // undefined
let b = null; // null
8. What is the use of the this keyword in JavaScript?
A: `this` refers to the current context/object where the code is being executed.
const person = {
name: "Mohit",
greet: function () {
console.log("Hello " + this.name);
}
};
9. What is Tailwind CSS?
A: Tailwind CSS is a utility-first CSS framework where you use small classes directly in HTML to design.
Example:
<div class="bg-blue-500 text-white p-4 rounded-lg">
Welcome to MK_Coder!
</div>
10. What are Cookies in web development?
A: Cookies are small pieces of data stored on the user's browser to remember information like login, cart, preferences, etc.
document.cookie = "username=Mohit; expires=Sun, 25 Aug 2025 12:00:00 UTC";
10 Web Development Interview Q&A – Part 6
1. Explain the CSS Box Model.
A: The CSS Box Model describes how HTML elements are rendered as boxes, comprising content, padding, border, and margin. Each part adds to the total space an element takes on the page.
- **Content:** The actual content of the element (text, images, etc.).
- **Padding:** Space between the content and the border.
- **Border:** A line around the padding and content.
- **Margin:** Space outside the border, separating the element from other elements.
2. What is the purpose of the `DOCTYPE` declaration in HTML?
A: The `DOCTYPE` declaration tells the web browser which version of HTML the page is written in. This helps the browser render the page correctly according to the specified HTML standard. For HTML5, it's a simple ` `.
3. What is the difference between `localStorage` and `sessionStorage`?
A: Both `localStorage` and `sessionStorage` are web storage objects that allow JavaScript sites to save key-value pairs in the browser.
- **`localStorage`:** Stores data with no expiration date; data persists even after the browser is closed and reopened.
- **`sessionStorage`:** Stores data only for the duration of the browser session; data is cleared when the browser tab or window is closed.
4. How do you include JavaScript in an HTML file?
A: JavaScript can be included in an HTML file in three main ways:
- **Inline:** Directly within HTML tags using the `on` event attributes (e.g.,
- **Internal:** Within ` tag. This is the preferred method for larger scripts.
5. What are CSS preprocessors, and why use them?
A: CSS preprocessors (like Sass, Less, Stylus) are scripting languages that extend CSS with features like variables, nesting, mixins, and functions that are not available in standard CSS. They make CSS more maintainable, reusable, and dynamic. The preprocessor code is then compiled into regular CSS that browsers can understand.
6. Explain the concept of "Mobile-First" design.
A: Mobile-First design is a responsive web design strategy where you start designing and developing for the smallest screen sizes (mobile devices) first, and then progressively enhance the design for larger screens (tables, desktops). This approach ensures optimal performance and user experience on mobile, and then adds complexity for larger views.
7. What is the DOM (Document Object Model)?
A: The DOM is a programming interface for web documents. It represents the page structure as a tree of objects, where each HTML element is a node. JavaScript can use the DOM to access, manipulate, and modify the content, structure, and style of a web page dynamically.
8. What is the difference between `==` and `===` in JavaScript?
A: Both are comparison operators in JavaScript:
- **`==` (Loose Equality):** Compares values after converting them to a common type (type coercion). For example, `5 == '5'` is true.
- **`===` (Strict Equality):** Compares values without type conversion. It checks both the value and the data type. For example, `5 === '5'` is false, but `5 === 5` is true. It's generally recommended for safer comparisons.
9. What is a CSS Framework? Give examples.
A: A CSS framework is a library of pre-written CSS code that provides ready-to-use styles, components, and utilities to speed up web development. They offer a structured way to build responsive and consistent user interfaces.
Examples: Bootstrap, Tailwind CSS, Bulma, Foundation.
10. What is version control, and why is Git important?
A: Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. It's essential for collaborative development and tracking changes.
**Git** is a widely used distributed version control system. It allows multiple developers to work on the same project simultaneously without overwriting each other's changes, track history, revert to previous versions, and manage different branches of a project.
10 Web Development Interview Q&A – Part 7
1. What is the difference between `display: none;` and `visibility: hidden;` in CSS?
A: Both hide an element, but they do so differently:
- **`display: none;`:** Removes the element completely from the document flow. It won't take up any space, and its descendants also become invisible.
- **`visibility: hidden;`:** Hides the element, but it still occupies its original space in the document flow. Its descendants can be made visible again by setting `visibility: visible;` on them.
2. Explain the concept of "Hoisting" in JavaScript.
A: Hoisting is a JavaScript mechanism where variable and function declarations are moved to the top of their containing scope during the compilation phase, before code execution. This means you can use a variable or call a function before it's formally declared in your code. However, only declarations are hoisted, not initializations.
console.log(myVar); // Outputs: undefined
var myVar = 10;
myFunction(); // Outputs: "Hello!"
function myFunction() {
console.log("Hello!");
}
3. What is the purpose
of the `alt` attribute
in the `
` tag?
A: The `alt` (alternative text) attribute provides a text description for an image. Its main purposes are:
- **Accessibility:** Screen readers use `alt` text to describe images to visually impaired users.
- **SEO:** Search engines use `alt` text to understand the content of an image, which can improve search rankings.
- **Fallback:** If the image fails to load, the `alt` text is displayed instead.
4. What is the difference between `let`, `const`, and `var` in JavaScript?
A: These keywords are used to declare variables in JavaScript, with key differences in scope and reassignability:
- **`var`:** Function-scoped, can be re-declared and re-assigned. Hoisted to the top of its function.
- **`let`:** Block-scoped, can be re-assigned but not re-declared within the same scope. Not hoisted (or rather, hoisted into a "temporal dead zone").
- **`const`:** Block-scoped, cannot be re-assigned or re-declared after its initial assignment. Must be initialized at declaration.
5. Explain the concept of "CSS Specificity".
A: CSS Specificity is an algorithm that determines which CSS rule's property value is applied to an element when multiple rules conflict. It's calculated based on the type of selectors used (inline styles, IDs, classes/attributes, element names). A more specific selector will override a less specific one.
Order of specificity (highest to lowest): Inline Style > ID Selector > Class/Attribute/Pseudo-class > Element/Pseudo-element.
6. What is an API (Application Programming Interface) in web development?
A: An API is a set of rules and protocols that allows different software applications to communicate with each other. In web development, APIs often define how a client (like a web browser or mobile app) can request data or functionality from a server (e.g., fetching weather data, processing payments, getting social media posts).
7. What is the difference between client-side and server-side rendering?
A: These refer to where the HTML for a web page is generated:
- **Client-Side Rendering (CSR):** The browser receives a minimal HTML file, and JavaScript then fetches data and builds the rest of the page directly in the user's browser. (e.g., React, Angular, Vue apps).
- **Server-Side Rendering (SSR):** The server generates the full HTML for the page on each request and sends it to the browser. The browser then displays the fully formed page. (e.g., traditional PHP, Python/Django, Node.js/Express apps).
8. What is a "Callback Function" in JavaScript?
A: A callback function is a function passed into another function as an argument, which is then executed inside the outer function at a later time. Callbacks are fundamental for asynchronous operations in JavaScript, like handling events, timers, or fetching data.
function greet(name, callback) {
console.log('Hello, ' + name);
callback();
}
function sayGoodbye() {
console.log('Goodbye!');
}
greet('Alice', sayGoodbye); // sayGoodbye is the callback function
9. What is the purpose of the `viewport` meta tag?
A: The `viewport` meta tag (` `) is crucial for responsive web design. It tells the browser how to control the page's dimensions and scaling. `width=device-width` sets the width of the page to the width of the device's screen, and `initial-scale=1.0` sets the initial zoom level when the page is first loaded.
10. What is "Cross-Origin Resource Sharing" (CORS)?
A: CORS is a security mechanism implemented in web browsers that restricts web pages from making requests to a different domain than the one that served the web page. It's a browser security feature to prevent malicious scripts from making unauthorized requests across domains. Servers need to explicitly allow cross-origin requests by sending appropriate CORS headers (e.g., `Access-Control-Allow-Origin`).
Bonus Practice Tip:
- Use Codepen.io or JSFiddle to practice HTML/CSS/JS live.
- Start building your portfolio website and try to add each concept you learn.