CSS Interview Questions and Answers for freshers
-
What is CSS?
- Answer: CSS stands for Cascading Style Sheets. It's a stylesheet language used to describe the presentation of a document written in HTML or XML. It controls aspects like colors, fonts, layout, and responsiveness of web pages.
-
Explain the box model in CSS.
- Answer: The box model is a fundamental concept in CSS. Every HTML element is treated as a rectangular box composed of: content (the actual text or image), padding (space between content and border), border (the line around the element), and margin (space between the element's border and other elements).
-
What are selectors in CSS? Give examples.
- Answer: Selectors target the HTML elements you want to style. Examples include: `element` (e.g., `p`), `class` (e.g., `.myclass`), `id` (e.g., `#myid`), `universal` (`*`), and combinators like `>` (child), `+` (adjacent sibling), `~` (general sibling).
-
Explain the difference between inline, internal, and external stylesheets.
- Answer: Inline styles are applied directly within HTML tags using the `style` attribute. Internal stylesheets are defined within the `