CSS Interview Questions and Answers for internship
-
What is CSS?
- Answer: CSS stands for Cascading Style Sheets. It's a language used to style HTML and XML documents. It describes how HTML elements should be displayed on screen, paper, or in other media. It controls things like colors, fonts, layout, and responsiveness.
-
Explain the box model.
- 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 images), padding (space between the content and border), border (the border around the element), and margin (space between the border and other elements).
-
What are selectors in CSS? Give examples.
- Answer: Selectors are patterns used to select HTML elements you want to style. Examples include: `*` (universal selector), `p` (element selector), `.class-name` (class selector), `#id-name` (ID selector), `p.class-name` (element and class selector), `p + p` (adjacent sibling selector), `p ~ p` (general sibling selector).
-
What is the difference between inline, internal, and external CSS?
- Answer: Inline CSS is applied directly within HTML elements using the `style` attribute. Internal CSS is placed within the `