CSS Questions
Warm up for CSS questions with most asked questions and answers for junior, mid, and senior roles.
What is Inline style?
Show AnswerHide Answer
Inline style is a style sheet that is applied to an element directly in the HTML code.
What is CSS?
Show AnswerHide 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.
What are the advantages of CSS?
Show AnswerHide 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.
In how many ways can a CSS be integrated as a web page?
Show AnswerHide Answer
A CSS file can be integrated as a web page in the following ways:
- Inline CSS.
- External CSS.
- Inline and External CSS.
How can the dimension be defined of an element ?
Show AnswerHide Answer
The dimension of an element can be defined by using the width and height properties.
What is the difference between the usage of an ID and a Class?
Show AnswerHide 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.
What is responsive web design?
Show AnswerHide Answer
Responsive web design is a web design technique that makes websites more accessible to users with different screen sizes and resolutions.
What is the use of % unit?
Show AnswerHide Answer
The % unit is used to specify the percentage of the width or height of the parent element.
What is RWD?
Show AnswerHide Answer
Responsive web design is a web design technique that makes websites more accessible to users with different screen sizes and resolutions.
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.
What is graceful degradation?
Show AnswerHide 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.
What is progressive enhancement?
Show AnswerHide 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.
What is Pseudo-elements ?
Show AnswerHide Answer
A CSS pseudo-element is a keyword added to a selector that lets you style a specific part of the selected elements.
What are the benefits of CSS sprites?
Show AnswerHide Answer
The benefits of using CSS sprites are:
- Reduces the number of http requests
- Improves SEO
- Reduces overall image size
Explain CSS specificity.
Show AnswerHide 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.