Web dev all question
Web dev all question
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.
Answer: Tags are elements enclosed in < >, and attributes provide additional information about an
element (e.g., <a href="url">Link</a>).
Answer: Block-level elements start on a new line (e.g., <div>, <p>), while inline elements do not (e.g.,
<span>, <a>).
Intermediate
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.
Answer: Inline (in an element), internal (in <style>), and external (in a separate .css file).
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:
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);
}
JavaScript Questions
Easy
1. What is JavaScript?
Answer: JavaScript is a lightweight, interpreted scripting language used to create dynamic web pages.
Answer: Variables store data. They are declared using var, let, or const.
Answer: Number, String, Boolean, Object, Undefined, Null, Symbol, and BigInt.
Intermediate
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.
Answer: The $() function is used to select elements and perform actions on them.
Intermediate
$("#button").on("click", function() {
alert("Button clicked!");
});
Hard
PHP Questions
Easy
1. What is PHP?
Answer: PHP (Hypertext Preprocessor) is a server-side scripting language used for web development.
Answer: Both output data, but echo is slightly faster and does not return a value, while print returns 1.
Intermediate
SQL Questions
Easy
Answer: DELETE removes specific rows, while TRUNCATE removes all rows and resets auto-increment
counters.
Answer: Rules enforced on data in tables (e.g., NOT NULL, PRIMARY KEY, UNIQUE).
Intermediate
Hard
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):
DDL commands are used to define and modify the structure of database
objects like tables, schemas, indexes, etc.
CREATE
ALTER
-- 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
DML commands are used to retrieve, insert, update, and delete data in a
database.
SELECT
-- 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
UPDATE
DELETE
COMMIT
SAVEPOINT
GRANT
REVOKE
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;
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
7. Aggregate Functions
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;
UNION
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!