CSS Questions
CSS Questions
Interview
Question
Sr.No Topic Number of Questions
1 Basic CSS 10
2 Selectors 4
3 CSS Box Model 7
4 Layout 8
5 Typography 7
6 Colors and Backgrounds 9
7 CSS Transition 5
8 CSS Animation 5
9 CSS Transform 10
10 CSS Flex 8
11 Grid Layout 10
12 Responsive Design 8
Total 91
Basic CSS
1. Inline styles: Directly within an HTML element.
2. Internal stylesheets: Within a <style> element in
the <head> section of an HTML document.
3. External stylesheets: inked to an HTML document
Q.1] What does CSS stand for? using the <link> element.
• CSS stands for Cascading Style Sheets. Q.6] What is an inline style?
Q.2] What is the purpose of CSS? • Inline styles are CSS styles applied directly to an
individual HTML element using the style attribute
• CSS is used to style and format the appearance of
web pages written in HTML and XML.
• It allows web developers to control aspects like
layout, colors, fonts, and spacing of HTML Q.7] What is an internal stylesheet?
elements.
• An internal stylesheet is CSS code written within a
Q.3] How do you link a CSS file to an HTML <style> element in the <head> section of an
document? HTML document.
• It applies styles to that particular HTML document
• You can link a CSS file to an HTML document using only.
the <link> element within the <head> section of
the HTML document. Q.8] What is an external stylesheet?
Class selector
• Defined using a dot (.) followed by a class name.
• Classes can be applied to multiple elements, and
one element can have multiple classes.
3. Class Selector (.)
✓ Selects elements with a specific class
attribute
4. ID Selector (#)
ID selector ✓ Selects a single element with a specific
• Defined using a hash (#) followed by an ID name. ID attribute
• IDs are unique within a document and should only
be applied to one element.
5. Attribute Selector
✓ Selects elements based on the presence
or value of an attribute.
Selectors
Q.11] What is a CSS selector?
2. Type Selector
10. Adjacent Sibling Selector (+) • It is a keyword added to the selectors which will
✓ Selects the first element that allow to style the specific parts of an element’s
immediately follows a specified element, content.
and both elements must have the same • Pseudo classes - targets the entire element
parent. • Pseudo elements – targets the specific part of an
element
• Pseudo-elements are written with a double colon
(::)
Q.15] What is the CSS box model? • To center an element vertically, you can use
Flexbox
• The CSS box model is a fundamental concept that
describes the rectangular boxes generated for
elements in a web page, which includes the
element's content, padding, border, and margin
LAYOUT
Q.23] What is the position property in CSS?
Q.24] Different Values of the position Property • Positioned relative to the viewport, meaning it
stays in the same place even when the page is
static Refer a codepen scrolled
• Default positioning
• Elements are positioned according to the normal
flow of the document.
• We can’t use offsets like top, right, bottom,
and left
TYPOGRAPHY
Q.31] How do you change the font of an
element? Q.36] How do you change the color of the text?
Syntax
• You can use multiple background images in an • We can change the opacity of an element using
element and position each one as needed using the opacity property
the background-position property.
• This allows for creative and flexible design
options.
Q.57] How do you translate an element using Q.61] What is the transform-origin property?
CSS?
• The transform-origin property specifies the point
around which a transformation is applied.
• You can translate an element using the
translate() function.
Main Axis
• The perspective property defines the perspective
from which a 3D element is viewed.
• It gives depth to 3D transformed elements. • The main axis is the primary axis along which flex
items are laid out.
• It is defined by the flex-direction property
• Directions
▪ row (default): The main axis runs
horizontally from left to right.
▪ row-reverse: The main axis runs
horizontally from right to left.
▪ column: The main axis runs vertically
from top to bottom.
▪ column-reverse: The main axis runs
vertically from bottom to top.
Cross Axis
Q.65] What is the backface-visibility
property? • The cross axis is perpendicular to the main axis.
• It runs in the opposite direction of the main axis
• The backface-visibility property • It is used for alignment and spacing of flex items.
• Directions
determines whether the back face of an
▪ When flex-direction is row or row-
element is visible when it is rotated reverse, the cross axis runs vertically.
▪ When flex-direction is column or
column-reverse, the cross axis runs
horizontally.
CSS FLEX
Q.66] What is Flexbox?
Row-reverse Column-reverse
Note:
• The grid-template-rows property defines the • The grid-gap property (now commonly referred to
number and height of rows in the grid. as gap) defines the spacing between rows and
columns in the grid.
• Similar to grid-template-columns, you can
specify the height using various units.
Q.83] How do you create a responsive grid layout? Q.87] How to Write a Media Query in CSS
Media Types
✓ all
✓ print
✓ screen
✓ speech
Media Features