CSS Interview Questions and Answers

100 CSS Interview Questions and Answers
  1. 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 the visual aspects of a website, such as colors, fonts, layout, and responsiveness.
  2. Explain the box model in CSS.

    • Answer: The box model is a fundamental concept in CSS. Every HTML element is rendered as a rectangular box. This box consists of: content (the actual text or image), padding (space between the content and border), border (the line around the element), and margin (space between the border and other elements).
  3. What are selectors in CSS? Give examples.

    • Answer: Selectors target specific HTML elements to which you want to apply styles. Examples include: element selectors (e.g., `p`, `div`), class selectors (e.g., `.myClass`), ID selectors (e.g., `#myID`), universal selector (`*`), and more complex selectors like combinators (+, >, ~).
  4. What is the difference between inline, internal, and external CSS?

    • Answer: Inline CSS applies styles directly within HTML tags using the `style` attribute. Internal CSS is embedded within the `