CSS Interview Questions

 CSS Interview Questions

A list of top frequently asked CSS interview questions and answers are given below.

1) What is CSS?

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.More details...

2) What is the origin of CSS?

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

3) How can you integrate CSS on a web page?

There are three methods to integrate CSS on web pages.

  1. Inline method - It is used to insert style sheets in an HTML document
  2. Embedded/Internal method - It is used to add a unique style to a single document
  3. Linked/Imported/External method - It is used when you want to make changes on multiple pages.

4) What are the advantages of CSS?

  • Bandwidth
  • Site-wide consistency
  • Page reformatting
  • Accessibility
  • Content separated from presentation

5) What are the limitations of CSS?

  • Ascending by selectors is not possible
  • Limitations of vertical control
  • No expressions
  • No column declaration
  • Pseudo-class not controlled by dynamic behavior
  • Rules, styles, targeting specific text not possible

6) What are the CSS frameworks?

CSS frameworks are the preplanned libraries that make easy and more standard compliant web page styling. The frequently used CSS frameworks are: -

  • Bootstrap
  • Foundation
  • Semantic UI
  • Gumby
  • Ulkit

7) Why background and color are separate properties if they should always be set together?

There are two reasons behind this:

  • 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.
  • Color is an inherited property while the background is not. So this can make confusion further.

8) What is Embedded Style Sheet?

An Embedded style sheet is a CSS style specification method used with HTML. You can embed the entire stylesheet in an HTML document by using the STYLE element. More details...

  1.  <style>    
  2. body {    
  3.     background-color: linen;    
  4. }    
  5. h1 {    
  6.     color: red;    
  7.     margin-left: 80px;    
  8. }     
  9. </style>    

9) What are the advantages of Embedded Style Sheets?

  • You can create classes for use on multiple tag types in the document.
  • You can use selector and grouping methods to apply styles in complex situations.
  • No extra download is required to import the information.

10) What is a CSS selector?

It is a string that identifies the elements to which a particular declaration apply. It is also referred as a link between the HTML document and the style sheet. It is equivalent of HTML elements. There are several different types of selectors in CSS: -

  • CSS Element Selector
  • CSS Id Selector
  • CSS Class Selector
  • CSS Universal Selector
  • CSS Group Selector

11) Name some CSS-style components.

Some CSS Style components are:

  • Selector
  • Property
  • Value

12) Which command is used for the selection of all the elements of a paragraph?

The p[lang] command is used for selecting all the elements of a paragraph.

13) What is the use of % unit?

It is used for defining percentage values.

14) Name the property used to specify the background color of an element.

The background-color property is used to specify the background color of the element. For example:

  1. <style>    
  2. h2,p{    
  3.     background-color: #b0d4de;    
  4. }    
  5. </style>  

15) Name the property for controlling the image repetition of the background.

The background-repeat property repeats the background image horizontally and vertically. Some images are repeated only horizontally or vertically.

  1. <style>    
  2. body {    
  3. background-image: url("paper1.gif");    
  4. margin-left:100px;    
  5. }    
  6. </style>  

16) What is the purpose of the z-index and how is it used?

The z-index helps to 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.

17) Name the property for controlling the image position in the background.

The background-position property is used to define the initial position of the background image. By default, the background image is placed on the top-left of the webpage.

18) What is the use of CSS Opacity?

The CSS opacity property is used to specify the transparency of an element. In simple words, you can say that it specifies the clarity of the image. In technical terms, Opacity is defined as the degree to which light is allowed to travel through an object. For example:

  1. <style>    
  2. img.trans {    
  3.     opacity: 0.4;    
  4.     filter: alpha(opacity=40); /* For IE8 and earlier */    
  5. }    
  6. </style>   


Popular posts from this blog

Accenture Jobs 2022 Insurance Domain

Infosys, Capgemini, Google, S&P are recruiting nerds, Check subtleties

Tesla lays off 200 Autopilot workers in most recent positions cut: Report