CSS Questions

Warm up for CSS questions with most asked questions and answers for junior, mid, and senior roles.

Junior

What is Inline style?

Show Answer

Inline style is a style sheet that is applied to an element directly in the HTML code.

Junior

What is CSS?

Show Answer

CSS is a language that describes the style of an HTML document. It is a way to describe the look and feel of a document without having to write HTML code.

Junior

What are the advantages of CSS?

Show Answer

Some of the advantages of CSS are:

  • Easier to maintain and update.
  • Greater consistency in design.
  • More formatting options.
  • Lightweight code.
  • Faster download times.
  • Search engine optimization benefits.
  • Ease of presenting different styles to different viewers.
  • Greater accessibility.
Junior

In how many ways can a CSS be integrated as a web page?

Show Answer

A CSS file can be integrated as a web page in the following ways:

  • Inline CSS.
  • External CSS.
  • Inline and External CSS.
Junior

How can the dimension be defined of an element ?

Show Answer

The dimension of an element can be defined by using the width and height properties.

Junior

What is the difference between the usage of an ID and a Class?

Show Answer

An ID is a unique identifier that is used to identify an element in a document. A Class is a group of elements that are used to style the elements in the document.

Junior

What is responsive web design?

Show Answer

Responsive web design is a web design technique that makes websites more accessible to users with different screen sizes and resolutions.

Junior

What is the use of % unit?

Show Answer

The % unit is used to specify the percentage of the width or height of the parent element.

Junior

What is RWD?

Show Answer

Responsive web design is a web design technique that makes websites more accessible to users with different screen sizes and resolutions.

Mid

What is the float property of CSS?

Show Answer

The float property specifies how an element should float.

Mid

How to restore the default property value using CSS?

Show Answer

To restore the default property value using CSS, you can use the 'initial' property value

Mid

What are the limitations of CSS?

Show Answer

Some of the limitations of CSS are:

  • CSS cannot perform any logical operations like if/else or for/while or +/-.
  • We can not read any files using CSS.
  • It can not interact with databases.
  • CSS can not request a web page.
Mid

What is the Z index?

Show Answer

The z-index property specifies the stack order of an element. An element with greater stack order is always in front of an element with a lower stack order.

Mid

What does CSS selector mean?

Show Answer

A CSS selector is a way to select a particular element in a document. It is used to select an element in a document by using a CSS selector.

Mid

Differentiate Class selector from ID selector?

Show Answer

Class selector is used to select an element by using a class name. ID selector is used to select an element by using an ID.

Mid

What is CSS Box Model?

Show Answer

Box Model it's a "box" that wraps around every HTML element. It consists of: margins, borders, padding, and the actual content.

It has the following properties:

  • Margin: It is the space between the element and its surrounding elements.
  • Border: It is the space between the element and its content.
  • Padding: It is the space between the element and its content.
  • Content: It is the actual content of the element.
    Mid

    What is meant by CSS frameworks?

    Show Answer

    A CSS framework is a library allowing for easier, more standards-compliant web design using the Cascading Style Sheets language.

    Mid

    Name a few prominent CSS frameworks.

    Show Answer

    Some of the most popular CSS frameworks are:

    • Easier to maintain and update.
    • Greater consistency in design.
    • More formatting options.
    • Lightweight code.
    • Faster download times.
    • Search engine optimization benefits.
    • Ease of presenting different styles to different viewers.
    • Greater accessibility.
    Mid

    Define gradients in CSS.

    Show Answer

    CSS gradients let you display smooth transitions between two or more specified colors.

    CSS defines three types of gradients:

    • Linear Gradients (goes down/up/left/right/diagonally)
    • Radial Gradients (defined by their center)
    • Conic Gradients (rotated around a center point)
    Mid

    What is the overflow property in CSS used for?

    Show Answer

    The overflow property is used to specify what happens when the content of an element is too large to fit inside the element.

    Mid

    What are the properties of flexbox?

    Show Answer

    The flex container properties are:

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

    Differentiate between absolute and relative in CSS

    Show Answer

    Relative: the element is positioned relative to its normal position. 

     

    Absolute: the element is positioned absolutely to its first positioned parent.

    Senior

    What is graceful degradation?

    Show Answer

    Graceful degradation is a design philosophy that centers around trying to build a modern web site/application that will work in the newest browsers, but falls back to an experience that while not as good still delivers essential content and functionality in older browsers.

    Senior

    What is progressive enhancement?

    Show Answer

    Progressive enhancement is a design philosophy that provides a baseline of essential content and functionality to as many users as possible, while delivering the best possible experience only to users of the most modern browsers that can run all the required code.

    Senior

    What is Pseudo-elements ?

    Show Answer

    A CSS pseudo-element is a keyword added to a selector that lets you style a specific part of the selected elements.

    Senior

    What are the benefits of CSS sprites?

    Show Answer

    The benefits of using CSS sprites are:

    • Reduces the number of http requests
    • Improves SEO
    • Reduces overall image size
      Senior

      Explain CSS specificity.

      Show Answer

      Specificity is the means by which browsers decide which CSS property values are the most relevant to an element and, therefore, will be applied. Simply put, if two CSS selectors apply to the same element, the one with higher specificity is used.