DEV Community

Thomas Wilfred
Thomas Wilfred

Posted on

CSS Interview Questions

CSS, an abbreviation for Cascading Style Sheets, is a style sheet language used for describing the layout of a document written in a markup language like HTML. It is one of the three technologies used to design the Web pages- the other two being HTML and Javascript. It is designed to enable the separation of presentation and content layout.

It has a simple syntax and uses a number of English keywords to specify the names of various style properties.

Now that we have discussed the basics of CSS, let us have a look at the important Interview questions based on CSS.

Q1- What is CSS?
Ans- CSS stands for Cascading Style Sheet. It is a popular styling language that is used with HTML to design websites. It can also be used with any XML documents including plain XML, SVG, and XUL.

Q2- What is the origin of CSS?
Ans- SGML (Standard Generalized Markup Language) is the origin of CSS. It is a language that defines markup languages.

Q3- Why background and color are the separate properties if they should always be set together?
Ans- There are two reasons behind this:

  1. It enhances the legibility of style sheets. The background property is a complex property in CSS, and if it is combined with color, the complexity will further increase.
  2. Color is an inherited property while the background is not. So this can make confusion further.

Q4- What are the different variations of CSS?
Ans- The variations for CSS are:

  1. CSS 1
  2. CSS 2
  3. CSS 2.1
  4. CSS 3
  5. CSS 4

Q5- Who maintains the CSS specifications?
Ans- World Wide Web(WWW) maintains the CSS specifications.

Q7- Discuss the merits and demerits of Embedded Style Sheets
Ans- There are several merits and demerits of embedded style sheets:
Merits of Embedded Style Sheets:

  1. Multiple tag types can be created in a single document.
  2. Styles, in complex situations, can be applied by using Selector and Grouping methods.
  3. The extra download is unnecessary.

Demerits of Embedded Style Sheets:

  1. Multiple documents cannot be controlled.

Q8- What is the purpose of Z-index and how is it used?
Ans- The z-index helps specify the stack order of positioned elements that may overlap one another. The z-index default value is zero and can take on either a positive or negative number.

An element with a higher z-index is always stacked above than a lower index.

Z-Index can take the following values:

Auto: Sets the stack order equal to its parents.
Number: Orders the stack order.
Initial: Sets this property to its default value (0).
Inherit: Inherits this property from its parent element.

Q9- What does CSS selector mean?
Ans- A string equivalent of HTML elements by which declarations or a set of it, is declared and is a link that can be referred for linking HTML and Style sheet is CSS selector.

Q10- What are the advantages of CSS?
Ans- Advantages of CSS are:

  1. Bandwidth
  2. Ease of use
  3. Website Speed
  4. Multiple Browser Support
  5. Device Compatability

Q11- What is the difference between CSS2 and CSS3?
Ans- The main difference between CSS2 and CSS3 is that CSS3 is divided into different sections which are also known as modules. Unlike CSS2, CSS3 modules are supported by many browsers.

Apart from that, CSS3 contains new General Sibling Combinators which is responsible for matching the sibling elements with the given elements.

I hope this article helped you in gaining some new information regarding CSS.

Top comments (3)

Collapse
 
voralagas profile image
Pravin Poudel • Edited

I believe the interview must somehow not only select a candidate but also provide fire to learn to those who are not selected. My favorite questions are the difference between padding and margin, different position types, and nowadays everybody favorite (except mine) i.e flex. Thanks for the post. Stay safe and take care

Collapse
 
thomaswilfred15 profile image
Thomas Wilfred

Hi. I regret that it is not up to your expectations. But this is an entry-level question that is aimed at sharing some basic knowledge about CSS. I will share some more information related to Advanced CSS very soon. Thanks for reading my article.

Collapse
 
voralagas profile image
Pravin Poudel • Edited

Actually, it may differ from the locality. Your country and my country are two contrast things in every way possible so experience over things might have differed. Thanks for sharing your overview. I am sure, I will learn even more things from your coming post. And sorry for my last reply, I think I was harsh on you that was not intentional. Good luck !!!