CSS Interview Questions

1. Name some CSS frameworks.

Ans: CSS frameworks are libraries that simplify web page styling. Examples include Bootstrap, Foundation, Gumby, UIkit, and Semantic UI.

2. What do you understand by the universal sector?

Ans: A universal selector (*) matches all elements on a page, regardless of their name or type. Instead of targeting specific tags (like p, div, or h1), it applies styles to every element in the HTML document.

Example:

html
<style>
* {
color: blue;
font-size: 10px;
}
</style>

In this example, every element on the page will have blue text and a font size of 10px.

3. Tell us about the use of the ruleset.

Ans: A ruleset is used to identify selectors, which can be applied to HTML elements. It consists of two main parts:

  • Selector: Specifies the HTML element(s) to be styled.

  • Declaration block: Contains one or more semicolon-separated declarations that define the styles to apply.

4. What are the elements of the CSS Box Model?

Ans: The CSS box model defines how elements are structured and spaced on a webpage. It consists of four parts: content (such as text or images), padding (space around the content), border (surrounding the padding), and margin (space outside the border).

5. Differentiate between CSS3 and CSS2.

Ans: The main difference between CSS3 and CSS2 is that CSS3 divides features into separate modules, allowing for easier updates and better browser support. CSS3 also introduces new selectors, such as the General Sibling Combinator (~), which allows matching elements that share the same parent and follow each other.

6. How can CSS be integrated into an HTML page?

Ans: There are three ways to integrate CSS into HTML: inline styling, internal CSS using <style> tags in the <head> section, and external CSS by linking a separate .css file using the <link> tag.

7. Explain a few advantages of CSS?

Ans: With CSS, a single stylesheet can control the design of multiple web pages. Styles can be grouped efficiently using selectors and grouping techniques, and multiple HTML elements can share common styles by assigning them the same class.

8. What is meant by RGB stream?

Ans: RGB represents colors in CSS using three components: Red, Green, and Blue. Each component’s intensity is defined by a value from 0 to 255, allowing CSS to render a wide spectrum of visible colors.

9. What was the purpose of developing CSS?

Ans: CSS was developed to define the visual appearance of websites, allowing developers to separate design from structure and content — something not possible before.

10. What is the difference between a class and an ID?

Ans: A class is used to style multiple HTML elements and is not unique, whereas an ID is unique and can be assigned to only one element on a page.