Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

### Basic CSS Questions

1. What does CSS stand for?


- Answer: Cascading Style Sheets

2. How do you link a CSS le to an HTML document?


- Answer: By using the `<link>` tag inside the `<head>` section: `<link rel="stylesheet"
href="styles.css">`

3. What is the di erence between an ID selector and a class selector in CSS?


- Answer: An ID selector is denoted by `#` and is unique within a page (`#id`), while a class
selector is denoted by `.` and can be used multiple times (`.class`).

4. How do you apply a style to all `<p>` elements?


- Answer: By using the element selector: `p { /* styles here */ }`

5. How can you center a block element horizontally with CSS?


- Answer: By setting the left and right margins to `auto`: `margin: 0 auto;`

### Intermediate CSS Questions

6. What is the di erence between `margin` and `padding` in CSS?


- Answer: `Margin` is the space outside an element's border, while `padding` is the space inside
the border, around the content.

7. Explain the box model in CSS.


- Answer: The box model consists of margins, borders, padding, and the content itself. It
de nes how elements are sized and spaced.

8. How do you make a exible grid layout using CSS Grid?


- Answer: By using properties like `display: grid;`, `grid-template-columns`, and `grid-template-
rows`.

9. What are pseudo-classes and pseudo-elements in CSS? Give an example of each.


- Answer: Pseudo-classes de ne the state of an element (e.g., `:hover`), and pseudo-elements
style speci c parts of an element (e.g., `::before`). Example: `a:hover { color: red; }`, `p::before
{ content: "Hello"; }`

10. How can you create a responsive layout using CSS?


- Answer: By using media queries: `@media (max-width: 600px) { /* styles for smaller screens
*/ }`
fi
fi
ff
ff
fl
fi
fi

You might also like