Here’s the complete, combined list of questions and answers across HTML, CSS, JavaScript, jQuery,
PHP, and SQL, including both the original questions and the additional concepts you asked to include.
Everything is categorized into easy, intermediate, and hard levels.
HTML Questions
Easy
1. What is HTML?
2. Answer: HTML (HyperText Markup Language) is the standard markup language for creating web
pages. It structures content on the web.
3. What are HTML tags and attributes?
Answer: Tags are elements enclosed in < >, and attributes provide additional information about an
element (e.g., <a href="url">Link</a>).
4. What is the difference between block-level and inline elements?
Answer: Block-level elements start on a new line (e.g., <div>, <p>), while inline elements do not (e.g.,
<span>, <a>).
Intermediate
4. What is the purpose of the meta tag in HTML?
Answer: The meta tag provides metadata like character encoding, viewport settings, and SEO
information (e.g., <meta name="description" content="example">).
5. What are semantic HTML elements? Give examples.
Answer: Semantic elements clearly define their meaning (e.g., <header>, <footer>,
<article>).
6. What are the input types supported in HTML forms?
Answer: Text, password, number, email, date, file, radio, checkbox, color, range, submit, reset,
and more.
Hard
7. What are ARIA roles, and how do they help with accessibility?
Answer: ARIA (Accessible Rich Internet Applications) roles improve accessibility by defining roles
and properties for elements (e.g., role="button", aria-live="polite").
CSS Questions
Easy
1. What is CSS?
Answer: CSS (Cascading Style Sheets) is used to style HTML elements, controlling layout, colors, fonts,
etc.
2. What are the different types of CSS?
Answer: Inline (in an element), internal (in <style>), and external (in a separate .css file).
3. What is the difference between id and class selectors?
Answer: id is unique and applies to one element, while class can be reused for multiple elements.
Intermediate
4. What is the difference between relative, absolute, and fixed positioning in CSS?
Answer:
a. relative: Position relative to its normal position.
b. absolute: Position relative to its nearest positioned ancestor.
c. fixed: Position relative to the viewport.
5. What is the difference between Flexbox and CSS Grid?
Answer: Flexbox is one-dimensional (handles rows or columns), while Grid is two-dimensional
(handles rows and columns).
6. How do you write a media query to apply styles for devices with a maximum width of 768px?
Answer:
@media (max-width: 768px) {
body {
font-size: 14px;
}
}
Hard
7. What are CSS custom properties (variables), and how are they used?
Answer: Custom properties are defined using -- and accessed using var().
:root {
--main-color: #3498db;
}
body {
background-color: var(--main-color);
}
8. What is the purpose of the z-index property in CSS?
Answer: The z-index property controls the stack order of elements. Higher values appear in
front of lower values.
JavaScript Questions
Easy
1. What is JavaScript?
Answer: JavaScript is a lightweight, interpreted scripting language used to create dynamic web pages.
2. What are variables, and how are they declared in JavaScript?
Answer: Variables store data. They are declared using var, let, or const.
3. What are the different data types in JavaScript?
Answer: Number, String, Boolean, Object, Undefined, Null, Symbol, and BigInt.
Intermediate
4. What is the difference between let, const, and var?
Answer:
a. var has function scope.
b. let has block scope and can be reassigned.
c. const has block scope and cannot be reassigned.
5. What is the difference between synchronous and asynchronous JavaScript?
Answer: Synchronous JavaScript runs code sequentially. Asynchronous JavaScript handles tasks
like API calls without blocking the main thread.
6. What is a promise in JavaScript?
Answer: A promise is an object representing the eventual completion or failure of an
asynchronous operation.
Hard
7. What is the event loop in JavaScript?
Answer: The event loop handles asynchronous operations by checking the call stack and task
queue to execute functions.
8. How does the try-catch block work in JavaScript?
Answer:
try {
console.log(undeclaredVariable);
} catch (error) {
console.error('Error:', error.message);
}
jQuery Questions
Easy
1. What is jQuery?
Answer: jQuery is a lightweight JavaScript library for simplifying DOM manipulation, event handling,
animations, and AJAX interactions.
2. What does the $() function do in jQuery?
Answer: The $() function is used to select elements and perform actions on them.
Intermediate
3. What is the difference between show() and fadeIn() in jQuery?
Answer: Both display hidden elements, but fadeIn() also applies a fade effect.
4. How can you attach an event listener in jQuery?
Answer:
$("#button").on("click", function() {
alert("Button clicked!");
});
Hard
5. How can you make an AJAX GET request in jQuery?
Answer: $.ajax({
url: "data.json",
method: "GET",
success: function(response) {
console.log(response);
},
error: function(error) {
console.log(error);
}
});
PHP Questions
Easy
1. What is PHP?
Answer: PHP (Hypertext Preprocessor) is a server-side scripting language used for web development.
2. What is the difference between echo and print in PHP?
Answer: Both output data, but echo is slightly faster and does not return a value, while print returns 1.
Intermediate
3. How do you connect PHP to a MySQL database?
Answer:
$conn = mysqli_connect("localhost", "username", "password", "database");
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
4. What is the purpose of include and require in PHP?
Answer: Both include files in a script, but require halts execution if the file is missing, while
include issues a warning.
Hard
5. Write an example of a class with a constructor and a method in PHP.
Answer: class Car {
public $model;
public function __construct($model) {
$this->model = $model;
}
public function displayModel() {
echo "The car model is " . $this->model;
}
}
$car = new Car("Toyota");
$car->displayModel();
SQL Questions
Easy
1. What is the difference between DELETE and TRUNCATE?
Answer: DELETE removes specific rows, while TRUNCATE removes all rows and resets auto-increment
counters.
2. What are SQL constraints?
Answer: Rules enforced on data in tables (e.g., NOT NULL, PRIMARY KEY, UNIQUE).
Intermediate
3. What is a transaction in SQL?
Answer: A transaction ensures a sequence of SQL statements executes as a unit, maintaining
data consistency.
4. What is a foreign key in SQL?
Answer: A foreign key is a column that establishes a link between two tables.
Hard
5. What are indexes in SQL, and why are they used?
Answer: Indexes improve query performance by allowing faster lookups. CREATE INDEX
idx_name ON employees(name);
This combined list includes all subtopics, and you can copy-paste this entire set. If you want further
expansions or customizations, let me know!
SQL Queries
Here’s a comprehensive list of SQL query syntax for all types of queries,
including DDL (Data Definition Language), DML (Data Manipulation
Language), TCL (Transaction Control Language), and DCL (Data Control
Language):
1. Data Definition Language (DDL)
DDL commands are used to define and modify the structure of database
objects like tables, schemas, indexes, etc.
CREATE
-- Create a new database
CREATE DATABASE database_name;
-- Create a new table
CREATE TABLE table_name (
column1 datatype constraints,
column2 datatype constraints,
...
);
-- Create an index
CREATE INDEX index_name ON table_name (column1, column2);
ALTER
-- Add a new column to a table
ALTER TABLE table_name ADD column_name datatype;
-- Modify the datatype or constraints of a column
ALTER TABLE table_name MODIFY column_name new_datatype;
-- Rename a column
ALTER TABLE table_name RENAME COLUMN old_column_name TO
new_column_name;
-- Drop a column
ALTER TABLE table_name DROP COLUMN column_name;
DROP
-- Drop a database
DROP DATABASE database_name;
-- Drop a table
DROP TABLE table_name;
-- Drop an index
DROP INDEX index_name ON table_name;
TRUNCATE
-- Remove all data from a table without logging individual
row deletions
TRUNCATE TABLE table_name;
2. Data Manipulation Language (DML)
DML commands are used to retrieve, insert, update, and delete data in a
database.
SELECT
-- Retrieve all columns
SELECT * FROM table_name;
-- Retrieve specific columns
SELECT column1, column2 FROM table_name;
-- Use WHERE clause to filter rows
SELECT * FROM table_name WHERE condition;
-- Use aggregate functions
SELECT COUNT(*), SUM(column_name), AVG(column_name) FROM
table_name;
-- Sorting results
SELECT * FROM table_name ORDER BY column_name ASC|DESC;
-- Grouping results
SELECT column_name, COUNT(*) FROM table_name GROUP BY
column_name;
INSERT
-- Insert data into all columns
INSERT INTO table_name VALUES (value1, value2, ...);
-- Insert data into specific columns
INSERT INTO table_name (column1, column2) VALUES (value1,
value2);
UPDATE
-- Update specific rows
UPDATE table_name
SET column1 = value1, column2 = value2
WHERE condition;
-- Update all rows
UPDATE table_name
SET column1 = value1;
DELETE
-- Delete specific rows
DELETE FROM table_name WHERE condition;
-- Delete all rows
DELETE FROM table_name;
3. Transaction Control Language (TCL)
TCL commands are used to manage transactions in the database.
COMMIT
-- Save the changes made by the transaction
COMMIT;
ROLLBACK
-- Undo the changes made by the transaction
ROLLBACK;
SAVEPOINT
-- Set a savepoint within a transaction
SAVEPOINT savepoint_name;
-- Rollback to a specific savepoint
ROLLBACK TO savepoint_name;
4. Data Control Language (DCL)
DCL commands are used to control access to data in the database.
GRANT
-- Grant privileges to a user
GRANT SELECT, INSERT, UPDATE ON table_name TO user_name;
REVOKE
-- Revoke privileges from a user
REVOKE SELECT, INSERT ON table_name FROM user_name;
5. Joins
Joins are used to retrieve data from multiple tables based on a related column.
INNER JOIN
SELECT columns
FROM table1
INNER JOIN table2
ON table1.common_column = table2.common_column;
LEFT JOIN
SELECT columns
FROM table1
LEFT JOIN table2
ON table1.common_column = table2.common_column;
RIGHT JOIN
SELECT columns
FROM table1
RIGHT JOIN table2
ON table1.common_column = table2.common_column;
FULL OUTER JOIN
SELECT columns
FROM table1
FULL OUTER JOIN table2
ON table1.common_column = table2.common_column;
CROSS JOIN
SELECT columns
FROM table1
CROSS JOIN table2;
6. Subqueries
-- Subquery in WHERE clause
SELECT column_name
FROM table_name
WHERE column_name = (SELECT column_name FROM table_name WHERE
condition);
-- Subquery in SELECT clause
SELECT column_name, (SELECT COUNT(*) FROM table_name WHERE
condition) AS alias_name
FROM table_name;
7. Aggregate Functions
-- Calculate the total number of rows
SELECT COUNT(*) FROM table_name;
-- Calculate the sum of a column
SELECT SUM(column_name) FROM table_name;
-- Find the average value of a column
SELECT AVG(column_name) FROM table_name;
-- Get the minimum and maximum value of a column
SELECT MIN(column_name), MAX(column_name) FROM table_name;
8. Constraints
-- Create a table with constraints
CREATE TABLE table_name (
column1 datatype PRIMARY KEY,
column2 datatype UNIQUE,
column3 datatype NOT NULL,
column4 datatype DEFAULT default_value,
column5 datatype,
FOREIGN KEY (column5) REFERENCES
another_table(another_column)
);
9. Views
-- Create a view
CREATE VIEW view_name AS
SELECT column1, column2
FROM table_name
WHERE condition;
-- Query a view
SELECT * FROM view_name;
-- Drop a view
DROP VIEW view_name;
10. Indexing
-- Create an index
CREATE INDEX index_name ON table_name (column_name);
-- Drop an index
DROP INDEX index_name ON table_name;
11. Advanced Queries
UNION
SELECT column1, column2 FROM table1
UNION
SELECT column1, column2 FROM table2;
EXISTS
SELECT column_name
FROM table_name
WHERE EXISTS (SELECT 1 FROM another_table WHERE condition);
CASE Statement
SELECT column1,
CASE
WHEN condition1 THEN result1
WHEN condition2 THEN result2
ELSE result3
END AS alias_name
FROM table_name;
This list should cover every SQL query syntax required for interviews,
practical applications, and projects. Let me know if there’s anything specific
you’d like to expand further!