CSS Interview Questions
Tags: css, webdev
Published: 2020-04-02 08:23:33

<b>CSS</b>, 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 <b>Interview questions based on <a href="https://codersera.com/blog/top-css-interview-questions-and-answers/">CSS</a></b>.

<img src="https://www.onlineinterviewquestions.com/storage/categories/June2018/css-interview-questions.jpg">

Q1- What is CSS?
Ans- <b>CSS</b> 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 (<i>Standard Generalized Markup Language</i>) is the origin of <a href="https://www.cssbasics.com/">CSS</a>. 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:
<b>Merits of Embedded Style Sheets</b>:
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.

<b>Demerits of Embedded Style Sheets</b>:
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:

<b>Auto</b>: Sets the stack order equal to its parents.
<b>Number</b>: Orders the stack order.
<b>Initial</b>: Sets this property to its default value (0).
<b>Inherit</b>: 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.