Top 70 CSS Interview Questions and Answers

    1 Votes

Frequently asked top CSS and CSS3 Interview Questions and Answers for freshers and 2-5 year experienced web developers.

1) What is Cascading Style Sheet (CSS) ?

CSS is used for applying the styles for the HTML elements. So in a typical HTML document CSS will be applied to complete document for styling the elements.

2) What does “Cascading” in CSS mean?
“Cascading” refers to the cascading order in HTML document. This will sort the declared CSS in an order to avoid the conflicts.
3) What are the different types of CSS?
Below are the different types of CSS –
  • Embedded – Adding the CSS styles in <style> attribute.
  • Inline – Adding the CSS to the HTML elements.
  • Linked/External – Adding the External CSS file to the HTML document.

 

4) Explain the advantages of CSS?

Below are some of the advantages of CSS –

  • Accessibility
  • Multiple Device Compatibility
  • Page will load fast
  • Maintenance is Easy
  • Offline Browsing

5) List out the components of CSS style?

Below are the different components of CSS styles –

  • Property 
  • Selector
  • Value

6) Explain type selector in CSS?

Type selector matches the element of specific type. To give the color for all inputs with text types, we can do like this.

input[type="text"]{
color: #b2bfc7;
}

7) Explain universal selector in CSS?

Universal selectors is used to match any element types. Below is the example for the same. For example,

* { 
color: #FFFFFF;
}

This rule is used to render the content of all elements in our document in white.

8) Explain descendant selector in CSS?

Descendant selectors are used when any style to be applied to an element when the element lies inside some element. For example,

ul em {
color: #FFFFFF;
}

As shown above style applied to element – “<em>” when it lies inside “<li>”.

9) Explain id selector in CSS?

Id selector is used to apply the style to an element based on the “id” of an element. For example,

#elementId {
color: #FFFFFF;
}

In the above code snippet all the elements having id – “elementId” will have the color white.

10) Explain class selector in CSS?

Class selector is used to apply the style to an element based on the “class name” of an element. For example,

.elementClassName {
color: #FFFFFF;
}

In the above code snippet all the elements having class name – “elementClassName” will have the color white.

11) Is it possible to make a class selector for a particular element? If so How?

Yes we can make a class selector for a particular element. Below is the example for the same –

h2.myelementClassName {
color: #FFFFFF;
}

Above example depicts whenever class name – “myelementClassName” found under element “h2” apply white color.

Page 1 of 6

Related Articles

HTML/HTML5 Interview Questions and Answers
JQuery Interview Questions and Answers
Javascript Interview Questions and Answers
Top AngularJS Questions and Answers
Top 60+ Node.JS Interview Questions and answers

Popular Videos

How to speak to people

How to speak so that people want to listen.

Got a tip or Question?
Let us know