CSS top 10 basic interview questions

Q1. What is CSS?

Ans. The full form of CSS is Cascading Style Sheets.This is use to style an HTML document. By using CSS we can create beautiful HTML document.

Q2. What is the use of CSS?

Ans. CSS is used to style website pages, It helps to design, layout and optimize the display of website for different devices and screen sizes.

Q3. what is a CSS selector?

Ans. The first part of a CSS Rule is called a CSS selector. This is a combination of elements, other tags & attributes that are used to select the HTML part on which CSS property values to be applied.

For Example:-

div p {
  text-align: left;
  color: yellow;
}

In the above code P, this is the selector.

Q4. How many ways we can use CSS on a web page?

Ans. We can use CSS in three ways on a web page:
(a) External CSS: In this way, we create a separate file of CSS with a .css extension.
(b) Internal CSS: In this way CSS code writes in HTML page in style tag.
(c) Inline CSS: In this way, we write CSS code in HTML tag in a style tag.

Q5. How to insert comments in CSS code?

Ans. The comments inside the code help to understand the other designer as well and they are ignored by the browser. In CSS code comments are starts with /* and end with */.

For example:-

/* This is a comment */
div p {
  color: yellow;
}

Q6. What is the difference between padding & margin in CSS?

Ans. Margin is used to create space around the HTML elements, the space is created outside of any defined border whereas the padding is used to create space around an HTML element’s content, the space is created inside of any defined borders.

Q7. What is position property in CSS?

Ans. The position property is use to define the location to element means where the element to be shown in the web page, it has following values:-

(a) Static (b) Relative (c) Fixed (d) Absolute (e) Sticky

Q8. What is the use of z-index in CSS?

Ans. When we need to place one element over another element we use z-index property. It specifies the which element should be placed on top and which is to be placed behind.

Q9. What are Pseudo-classes in CSS?

Ans. The pseudo-class helps to apply CSS property on a element in a specific state of that element. Means we can define different property on different state of elements:-

The pseudo-class can be used to:
(a) Apply style on an element when a user mouses over the element.
(b) Apply style on visited and unvisited links differently.
(c) Apply style on an element when it gets focus.

Q10. What are the limitations of CSS?

Ans. The CSS disadvantages are given below:-
(a) Browser Compatibility: We have to write different CSS for different browsers.
(b) Cross Browser issue: Some selectors works differently in a different browsers.
(c) No parent selector: We can’t select a parent tag in CSS.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top