CSS Interview Questions for front end Developer

css interview questions for front end developer
css interview questions for front end developer

Introduction:

CSS stands for Cascading Style Sheet.CSS was developed and is maintained by the World Wide Web Consortium (W3C).

Cascading Style Sheets Level 3 (CSS3) is the third version of the CSS standard that is used to style and format web pages. The main change in CSS3 is the inclusion of divisions of standards into different modules that makes CSS3 easier to learn and understand.

Cascading style sheet interview questions and Answer:

Question 1:What is the correct HTML for referring to an external style sheet?

Answer:<link rel=”stylesheet” type=”text/css” href=”databeatutiful.css”>

Question 2:Where in an HTML document is the correct place to refer to an external style sheet?

Answer:In the Head Secion of HTML Page

Question 3:Which HTML tag is used to define an internal style sheet?

Answer:<Style> tag we are using in the internal style sheet eg:

<style type=”text/css”>

color:red;

</style>

Question 4:Which HTML attribute is used to define inline styles?

Answer: When we work inline styles so we are using just Style e.g:

<H1 style=”background-color:red;”>

Question 5:How do you insert a comment in a CSS file?

Answer::  /* here is your code… */

Question 6:Which property is used to change the background color?

Answer: background-color:red;

Question 7:How do you add a background color in any tag elements?

Answer:tagname{ background-color:#ccff99; }

Question 8:Which CSS property is used to change the text color of an element?

Answer: we are using just color property to change the text color.

Question 9:Which CSS property controls the text size?

Answer: font-size we use.

Question 10:What is the correct CSS syntax for making all the <td> elements bold?

Answer:td{font-weight:bold;}

Question 11:How do you display hyperlinks without an underline?

Answer:a {text-decoration:none;} 

Question 12:How do you make each word in a text start with a capital letter?

Answer:text-transform:capitalize

Question 13:How do you make the text bold?

Answer:font-weight:bold;

Question 14:How do you display a border like this?

Answer:border-width:20px 1px 5px 20px; look like this

  1. Top border=20px;
  2. bottom border=5px;
  3. left border=20px;
  4. right border=1px;

Question 15:How do you select an element with id ‘demo’?

Answer: #demo . # is used for ID

Question 16:How do you select elements with class name ‘demo’?

Answer: .demo : dot (.) us used for class element .

Question 17:How do you select all a elements inside a div element?

Answer: div a

Question 18:What is the Box model in CSS?

Answer: A rectangle box is a wrapper around every HTML element. The wrapper class Div contains all HTML tag in one box. All HTML element tags closed inside wrapped div. The diagram is given below :

Css Div Box
CSS wrapper Div
  • Content:  Actual Content of the box where the text or image is placed.
  • Padding: Area surrounding the content (Space between the border and content).
  • Border: Area surrounding the padding.
  • Margin: Area surrounding the border.

Question 19:What are the limitations of CSS?

Answer: Browser Compatibility: Some style selectors are supported and some are not. we have to identify to check which style sheet is supported.

Cross Browser issue: Some selectors behave differently in a different browser

There is no parent selector: You can’t select the parent tag.

Question 20:What are the different types of Selectors in CSS?

Answer: There are seven types:

  • Universal Selector:
  • Element Type Selector
  • ID Selector
  • Class Selector
  • Descendant Combinator
  • Child Combinator
  • Attribute Selector

1. Universal Selector:

* { color: “green”; font-size: 20px; line-height: 25px; }

2.Element Type Selector:

ul { line-style: none; border: solid 1px #ccc; }

3.ID Selector:

#container { width: 960px; margin: 0 auto; } <div id=”container”></div>

4.Class Selector:.

box { padding: 10px; margin: 10px; width: 240px; } <div class=”box”></div>

5.Descendant Combinator:

#container .box { float: left; padding-bottom: 15px; }

<div id=”container”> <div class=”box”></div>

<div class=”box-2″></div> </div>

<div class=”box”></div>

6.Child Combinator:

#container .box { float: left; padding-bottom: 15px; }

<div id=”container”> <div class=”box”></div>

<div> <div class=”box”></div> </div> </div>

7. Attribute Selector:

input [type=”text”] { background-color: #444; width: 200px; }

<input type=”text”>

Question 21:How is opacity specified in CSS3?

Answer: We can use the property name opacity which takes the values ranging from 0 to 1. 0 specifies that the element is completely transparent. Eg:

 div { opacity: 0.6; }

Question 22:What are the properties of flexbox?

Answer: Flexbox stands for flexible box with the purpose of providing an efficient way to handle layouts, align elements within them. Flexbox distributes spaces amongst the items in dynamic/responsive conditions.

The properties of flexbox are as follows:

  • flex-direction
  • flex-wrap
  • flex-flow
  • justify-content
  • align-items
  • align-content

Question 23:What is CSS position property?

Answer: There are five position properties in CSS

  1. Absolute
  2. Relative
  3. Fixed
  4. Static
  5. Sticky

Question 24:  Can you name the four types of @media properties?

Answer: The four types of @media properties are:

  1. All : Used for all media-type devices
  2. Screen : Used for computer screen, mobile screen
  3. Print :Used for printers
  4. Speech :Used for screen readers

Question 25:Define float property of CSS?

Answer: By float property, the image can be moved to the right or the left along with the text to be wrapped around it.

float-left:10px;

float-right:20px;

You may also like:

Be the first to comment

Leave a Reply

Your email address will not be published.


*