All CSS Interview Questions & Answers

Top CSS Interview Questions & Answers Collection:

CSS stands for “Cascading Style Sheet”. CSS is used to style such as color, font, size, border of the web page.

Here, you can find Frequently Asked CSS Interview Questions & Answers for jobs. These are top Interview Questions related to CSS Text, border, padding, margin, position, color, font, selectors, fonts etc.

Tutorials Class covers Interview Questions for Freshers as well as experienced professionals.

What is CSS class selector?

A CSS class is used to group similar HTML elements. This helps us to apply same style to those elements by placing them in the same class.

Class methods can be called by inserting a ‘class’ property and name within an HTML element

<p class="green"> Sample Text </p>
<p class="green"> Sample Text </p>
<p class="green"> Sample Text </p>

Then, we can call class name with a '.' in the CSS file. For example:
.green { color: green; }

What is grouping in CSS and what is it used for?

Grouping allows you to apply the same style to multiple elements(classes/tag/id) with a single declaration. This is done by listing all the selectors, separated by commas.


#maincontent p, ul { border-top: 1px solid #ddd; }

Explain the various ways to apply CSS styles to a Web page?

There are Four methods of adding CSS to HTML.

  1. Inline: by inserting a style attribute inside an <head> element.
  2. Embedded/Internal: by putting all css inside head using <style> tags
  3. Linked/External: CSS is placed in an external .css file, and linked to the HTML document using a <link> tag.
  4. Imported: Importing a CSS file using @import

What are child selectors?

Child selectors are written using a greater-than symbol (>), and it must appear between two other selectors. This is used to match elements that are direct children of other elements, which is a little more precise than the traditional selectors.

Example: body > a {color: blue;}

What is the use of float property in CSS?

The float property determines whether or not a box (an element) should float. Floats allow an element to be positioned horizontally, by pushing a block-level element to the right or left.

Why we use shorthand properties in CSS?

CSS shorthand properties helps to improve page load times and reduce file size.
For an example: All CSS border Properties can be set in a single line in a specific order.
Example: p { border: 4px dotted black; }