What does CSS stand for?
- A
Cascading Style Sheets
- B
Creative Style Sheets
- C
Computer Style Sheets
- D
Colorful Style Sheets
Master CSS with 130+ curated MCQs covering selectors, box model, flexbox, grid, responsive design, animations, and more. Perfect for exams, interviews, and placements.
What does CSS stand for?
Cascading Style Sheets
Creative Style Sheets
Computer Style Sheets
Colorful Style Sheets
Which HTML tag is used to define an internal style sheet?
<style>
<css>
<script>
<link>
Which property is used to change the background color?
background-color
color
bgcolor
background
How do you add a comment in CSS?
// comment
/* comment */
<!-- comment -->
# comment
Which CSS property controls the text size?
font-size
text-size
font-style
size
Which is the correct CSS syntax?
body {color: black;}
body {color: black}
body:color=black;
{body:color=black;}
Which selector is used to select elements with a specific class?
.class
#class
*class
class
Which selector is used to select an element with a specific id?
#id
.id
*id
id
What does the universal selector (*) do?
Selects all elements
Selects the first element
Selects the last element
Selects elements with a class
Which selector selects elements that are direct children of a specific parent?
parent > child
parent child
parent + child
parent ~ child
What is the difference between a class and an id selector?
An id is unique; a class can be used multiple times
A class is unique; an id can be used multiple times
Both are the same
Id is used for styling, class for scripting
Which attribute selector selects elements with a specific attribute?
[attribute]
#attribute
.attribute
*attribute
What does the CSS box model consist of?
Content, padding, border, margin
Content, border, margin
Padding, border, margin
Content, padding, margin
Which property is used to add space inside an element's border?
padding
margin
spacing
border-spacing
Which property is used to add space outside an element's border?
margin
padding
border
outline
What is the default value of the box-sizing property?
content-box
border-box
padding-box
margin-box
Which property allows you to round the corners of an element?
border-radius
border-corner
corner-radius
radius
What is the difference between margin and padding?
Margin is outside the border; padding is inside
Padding is outside; margin is inside
Both are the same
Margin affects background, padding does not
Which CSS property is used to set the text color?
color
text-color
font-color
foreground-color
Which property is used to set a background image?
background-image
bg-image
background
image
Which value of background-repeat prevents the background image from repeating?
no-repeat
repeat
repeat-x
repeat-y
What is the correct way to specify a linear gradient in CSS?
background: linear-gradient(red, yellow);
background: gradient(red, yellow);
background: linear(red, yellow);
background: gradient-linear(red, yellow);
Which CSS color value represents a color using opacity?
rgba()
rgb()
hex
hsl()
What does the background-size property do?
Sets the size of the background image
Sets the size of the element
Sets the size of the text
Sets the padding
Which property is used to change the font family of text?
font-family
font-style
font-weight
font-size
Which property is used to make text bold?
font-weight: bold;
font-style: bold;
text-decoration: bold;
font: bold;
Which property is used to underline text?
text-decoration: underline;
text-underline: yes;
font-decoration: underline;
underline: true;
Which property is used to change the text alignment?
text-align
align-text
horizontal-align
text-justify
Which property is used to set the spacing between lines?
line-height
letter-spacing
word-spacing
text-spacing
Which property is used to create a drop cap effect?
::first-letter
::first-line
:first-letter
:first-line
Which display value creates a flex container?
display: flex;
display: block;
display: inline;
display: grid;
Which property defines the direction of flex items?
flex-direction
flex-wrap
flex-flow
justify-content
Which property aligns flex items along the main axis?
justify-content
align-items
align-content
align-self
Which property aligns flex items along the cross axis?
align-items
justify-content
align-content
align-self
What does flex-wrap: wrap; do?
Allows items to wrap onto multiple lines
Prevents items from wrapping
Wraps items in reverse order
Automatically adjusts item size
Which property controls the ability of a flex item to grow?
flex-grow
flex-shrink
flex-basis
flex
Which display value creates a grid container?
display: grid;
display: flex;
display: block;
display: inline-grid;
Which property defines the columns of a grid?
grid-template-columns
grid-template-rows
grid-columns
grid-rows
Which property defines the rows of a grid?
grid-template-rows
grid-template-columns
grid-rows
grid-columns
What does the fr unit represent in CSS Grid?
Fractional unit of available space
Fixed unit
Percentage
Pixel
Which property specifies the gap between grid rows?
row-gap
column-gap
grid-gap
gap
How do you place a grid item in a specific column?
grid-column-start / grid-column-end
grid-row-start / grid-row-end
grid-area
Both A and C
Which CSS position value removes the element from normal flow?
absolute
relative
fixed
sticky
Which position value positions an element relative to its normal position?
relative
absolute
fixed
static
Which position value positions an element relative to the viewport?
fixed
absolute
relative
static
What is the default value of the position property?
static
relative
absolute
inherit
Which property is used to control the stacking order of positioned elements?
z-index
order
stack
layer
What is the difference between position: sticky and position: fixed?
Sticky toggles between relative and fixed based on scroll
Fixed toggles between relative and absolute
Both are the same
Sticky is only for tables
Which CSS feature is used to apply styles based on screen size?
Media Queries
Viewport Meta Tag
Flexbox
Grid
What is the correct syntax for a media query targeting screens with max-width 600px?
@media (max-width: 600px) { ... }
@media screen and (max-width: 600px) { ... }
@media max-width: 600px { ... }
Both A and B
Which CSS unit is relative to the viewport height?
vh
vw
vmin
vmax
Which CSS unit is relative to the viewport width?
vw
vh
vmin
vmax
What is a mobile-first approach in CSS?
Design for mobile first, then scale up
Design for desktop first, then scale down
Design for tablet first
Design for all devices simultaneously
Which meta tag is used to control the viewport on mobile devices?
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<meta name='mobile' content='width=device-width'>
<meta name='screen' content='width=device-width'>
<meta name='responsive' content='yes'>
Which property is used to create a smooth transition effect?
transition
animation
transform
keyframes
Which CSS rule is used to define keyframes for animation?
@keyframes
@frames
@animation
@move
Which property defines the duration of an animation?
animation-duration
transition-duration
animation-timing-function
transition-timing-function
Which property makes an element rotate?
transform: rotate(45deg);
transform: skew(45deg);
transform: scale(1.5);
transform: translate(45px);
What is the difference between transition and animation?
Transition is triggered by state change; animation runs automatically
Animation is triggered by state change; transition runs automatically
They are the same
Transition can repeat, animation cannot
Which property specifies the number of times an animation should run?
animation-iteration-count
animation-count
animation-repeat
animation-play-state
How do you define a CSS variable?
--variable-name: value;
$variable-name: value;
@variable-name: value;
var: variable-name: value;
How do you use a CSS variable?
var(--variable-name)
var(variable-name)
$(variable-name)
@(variable-name)
Where should CSS variables be defined to be globally accessible?
:root
html
body
*
Can CSS variables be used in media queries?
Yes
No
Only in some browsers
Only if defined inline
Which function is used to set a fallback value for a CSS variable?
var(--name, fallback)
fallback(--name)
set(--name, fallback)
use(--name, fallback)
What is the scope of a CSS variable defined inside a specific selector?
Only within that selector and its children
Global to the entire document
Only within that selector
Only within the parent of that selector
Which CSS property is used to hide an element while still taking up space?
visibility: hidden;
display: none;
opacity: 0;
hidden: true;
Which selector selects elements that are first child of their parent?
:first-child
:first-of-type
:nth-child(1)
All of the above
Which property is used to set the width of an element including padding and border?
box-sizing: border-box;
box-sizing: content-box;
width: 100%;
padding-box
Which property is used to set the opacity of an element?
opacity
transparency
alpha
filter: opacity
Which property is used to capitalize text?
text-transform: capitalize;
text-transform: uppercase;
font-variant: small-caps;
capitalize: yes;
Which property is used to change the order of flex items?
order
flex-order
item-order
align-self
Which property is used to define areas for grid items?
grid-template-areas
grid-areas
grid-template
grid-area
Which property is used to clip an element?
clip
clip-path
overflow
Both A and B
What is a breakpoint in responsive design?
A specific screen width where the layout changes
A CSS property
A JavaScript function
A type of media
Which property specifies the timing function of a transition?
transition-timing-function
transition-delay
transition-property
transition-duration
Can CSS variables be used in calc() functions?
Yes
No
Only if numeric
Only in some browsers
What does the 'inherit' keyword do?
Takes the value from the parent element
Sets the default value
Resets the property
Defines a custom value
Which selector selects the last child of a parent?
:last-child
:last-of-type
:nth-last-child(1)
All of the above
Which property is used to add a shadow to an element?
box-shadow
shadow
element-shadow
border-shadow
Which property is used to set multiple background images?
background-image
background
backgrounds
image
Which property is used to set the distance between characters?
letter-spacing
word-spacing
character-spacing
text-spacing
Which property aligns a single flex item along the cross axis?
align-self
align-items
justify-self
order
Which property is used to name grid lines?
grid-template-rows
grid-template-columns
grid-line-names
grid-name
What is the purpose of the 'overflow' property?
Controls what happens when content overflows the box
Hides the element
Adds a scrollbar
Both A and C
Which unit is relative to the font size of the root element?
rem
em
px
pt
Which property is used to make an element scale?
transform: scale(2);
transform: rotate(2);
transform: skew(2);
transform: translate(2);
Can CSS variables be used in combination with calc()?
Yes
No
Only if variables are numeric
Only in some browsers
Which property is used to control the cursor style?
cursor
pointer
cursor-style
mouse
Which selector selects elements that have no children?
:empty
:blank
:void
:null
Which property is used to set the outline of an element?
outline
border
shadow
box-shadow
Which color value uses a hue, saturation, and lightness?
hsl()
rgb()
hex
rgba()
Which property is used to set the font style to italic?
font-style: italic;
font-style: oblique;
font-weight: italic;
text-style: italic;
Which property defines the default size of a flex item?
flex-basis
flex-grow
flex-shrink
width
Which property is used to create a grid with equal columns?
grid-template-columns: repeat(3, 1fr);
grid-template-columns: 1fr 1fr 1fr;
Both A and B
grid: 3 columns;
Which property is used to set the position of a positioned element?
top, right, bottom, left
position
offset
align
Which viewport unit is equal to 1% of the viewport's smaller dimension?
vmin
vmax
vw
vh
Which property specifies the delay before an animation starts?
animation-delay
transition-delay
animation-start
transition-start
Can CSS variables be used in @media queries?
Yes
No
Only in some browsers
Only if defined inline
What is the default display value of a div?
block
inline
inline-block
flex
Which selector selects the nth child of a parent?
:nth-child(n)
:nth-of-type(n)
:nth(n)
:child(n)
Which property is used to set the margin of an element?
margin
padding
border
spacing
Which property is used to set the background position?
background-position
bg-position
background-align
position
Which property is used to set the weight of the font?
font-weight
font-size
font-style
font-family
Which property aligns flex lines when there is extra space in the cross axis?
align-content
align-items
justify-content
align-self
Which property places a grid item in a specific area?
grid-area
grid-column
grid-row
All of the above
Which position value positions an element based on the nearest positioned ancestor?
absolute
relative
fixed
sticky
What is the purpose of a media query?
Apply styles based on device characteristics
Apply styles based on user preference
Apply styles based on browser version
Apply styles based on time
Which property is used to create a 3D transform?
transform: rotateX(45deg);
transform: rotateZ(45deg);
transform: translate3d();
All of the above
What is the default value of a CSS variable if not defined?
It is invalid and ignored
It is 0
It is inherit
It is initial
Which CSS property is used to change the list item marker?
list-style-type
list-style
marker-type
item-marker
Which selector selects elements that are not a specific element?
:not(selector)
:exclude(selector)
:except(selector)
:no(selector)
Which property is used to set the border style?
border-style
border-type
border
border-width
Which CSS function is used to create a radial gradient?
radial-gradient()
linear-gradient()
conic-gradient()
gradient()
Which property is used to set the text shadow?
text-shadow
shadow
font-shadow
box-shadow
Which property defines the ability of a flex item to shrink?
flex-shrink
flex-grow
flex-basis
flex
Which property is used to set the gap between grid items?
gap
grid-gap
row-gap
All of the above
Which property is used to control whether an element can be positioned relative to the nearest positioned ancestor?
position: absolute;
position: fixed;
position: relative;
position: static;
Which CSS unit is relative to the font size of the element?
em
rem
px
pt
Which property is used to pause or play an animation?
animation-play-state
animation-pause
animation-state
animation-control
Can CSS variables be used in gradients?
Yes
No
Only in linear gradients
Only in radial gradients
Which property is used to set the direction of text?
direction
text-direction
writing-mode
unicode-bidi
Which selector selects the first line of a block of text?
::first-line
:first-line
::first-letter
first-line
Which property is used to set the padding of an element?
padding
margin
border
spacing
Which property is used to set the background attachment?
background-attachment
bg-attachment
background-scroll
attachment
Which property is used to set the text decoration style?
text-decoration-style
text-decoration-line
text-decoration
decoration-style
Which property is a shorthand for flex-grow, flex-shrink, and flex-basis?
flex
flex-flow
flex-wrap
flex-direction
Which property defines the size of a grid column?
grid-column-size
grid-template-columns
grid-column
grid-size
Which position value is used to make an element stick to the top when scrolling?
sticky
fixed
absolute
relative
What is the recommended approach for responsive images?
Using srcset and sizes attributes
Using max-width: 100%;
Using picture element
All of the above
Which property is used to create a transition effect on a specific property?
transition-property
transition-duration
transition-timing-function
transition-delay