CSS Questions

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

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.