1. What is HTML?
HTML is the standard markup language used to create the structure of web pages.
2. What are HTML tags?
Tags are elements enclosed in angle brackets like <p>, <div>, or <a>. They define
how content should be displayed.
3. What is the difference between <div> and <span>?
<div> is a block-level element.
<span> is an inline element.
4. What is the purpose of the <head> tag?
Contains metadata, links to stylesheets, scripts, etc., and is not visible on the
page.
5. What is semantic HTML?
HTML that uses meaningful tags like <article>, <section>, <nav> to describe
content.
6. What is the difference between id and class?
id is unique and used for one element.
class can be shared across multiple elements.
7. How do you create a link in HTML?
<a href="https://example.com">Visit Site</a>
8. How do you insert an image in HTML?
<img src="image.jpg" alt="Description" />
9. What is the use of the <form> tag?
Used to collect user input and submit it to a server.
10. What are some self-closing tags in HTML5?
<img>, <br>, <hr>, <input>, <meta>, <link>
11. What are the new elements in HTML5?
<header>, <footer>, <article>, <section>, <nav>, <figure>, <aside>
12. What is the alt attribute used for in images?
Provides alternative text for an image if it can’t be displayed and improves
accessibility.
13. What is the difference between <ul>, <ol>, and <dl>?
<ul>: Unordered list
<ol>: Ordered list
<dl>: Definition list
14. What is CSS?
CSS is used to style and layout HTML elements on a web page.
15. What are the different types of CSS?
Inline (style="" in element)
Internal (<style> in head)
External (<link href="style.css">)
16. What is the difference between em, rem, and px units?
px: Absolute unit
em: Relative to parent font size
rem: Relative to root (html) font size
17. What is the box model in CSS?
Every HTML element is a box with:
content
padding
border
margin
18. What is the difference between relative, absolute, and fixed positioning?
relative: Positioned relative to its normal position
absolute: Positioned relative to the nearest positioned ancestor
fixed: Stays fixed on screen (relative to viewport)
19. What are pseudo-classes in CSS?
Special keywords added to selectors, like :hover, :first-child, :nth-child(n).
20. How do you center an element in CSS?
margin: auto;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
21. What is specificity in CSS?
It determines which CSS rule is applied when multiple rules match the same element.
22. What is the difference between inline, block, and inline-block?
inline: Doesn't respect width/height
block: Takes full width
inline-block: Behaves like inline but respects width/height
23. How do you apply a CSS class to an element?
<div class="box"></div>
24. What is the difference between visibility: hidden and display: none?
visibility: hidden: Element is invisible but takes up space
display: none: Element is removed from layout
25. What is a media query?
Used to apply CSS based on screen size or device type.
@media (max-width: 768px) {
body {
background-color: lightblue;
}
}