CSS Questions
Warm up for CSS questions with most asked questions and answers for junior, mid, and senior roles.
What is the float property of CSS?
Show AnswerHide Answer
The float property specifies how an element should float.
How to restore the default property value using CSS?
Show AnswerHide Answer
To restore the default property value using CSS, you can use the 'initial' property value
What are the limitations of CSS?
Show AnswerHide 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.
What is the Z index?
Show AnswerHide 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.
What does CSS selector mean?
Show AnswerHide 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.
Differentiate Class selector from ID selector?
Show AnswerHide 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.
What is CSS Box Model?
Show AnswerHide 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.
What is meant by CSS frameworks?
Show AnswerHide Answer
A CSS framework is a library allowing for easier, more standards-compliant web design using the Cascading Style Sheets language.
Name a few prominent CSS frameworks.
Show AnswerHide 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.
Define gradients in CSS.
Show AnswerHide 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)
What is the overflow property in CSS used for?
Show AnswerHide Answer
The overflow property is used to specify what happens when the content of an element is too large to fit inside the element.
What are the properties of flexbox?
Show AnswerHide Answer
The flex container properties are:
- flex-direction
- flex-wrap
- flex-flow
- justify-content
- align-items
- align-content
Differentiate between absolute and relative in CSS
Show AnswerHide Answer
Relative: the element is positioned relative to its normal position.
Absolute: the element is positioned absolutely to its first positioned parent.