Advanced CSS Interview Preparation Structure
Level Type
Advanced Specificity, animations, grid, variables, transitions, preprocessors
1. What is the difference between
em
, rem
, px
, %
?Ans.
px
: absolute unitsem
: relative to parentrem
: relative to root (html
)%
: relative to parent element
2. What are media queries?
Ans.
Allow you to apply CSS based on screen size or device:
css file
@media (min-width: 600px) {
.box {
width: 50%;
}
}
3. How do you create animations in CSS?
Ans.
in css file
@keyframes slide {
from {
left: 0;
}
to {
left: 100px;
}
}
.box {
animation: slide 2s ease-in-out;
}
4. What is
flexbox
in CSS?Ans.
A layout model to arrange items in rows or columns. Example:
in css file
.container {
display: flex;
justify-content: center;
align-items: center;
}
5. Difference between
inline
, block
, and inline-block
?Ans.
inline
: cannot set width/heightblock
: takes full widthinline-block
: allows setting width/height, behaves inline
6. What is specificity in CSS?
Ans.
Priority of applying CSS rules.
Inline > ID > Class > Element
7. What is the difference between
visibility: hidden
and display: none
?Ans.
visibility: hidden
hides the element but keeps spacedisplay: none
removes it from the layout
8. What is the
calc()
function?Ans.
calc()
is a CSS function that lets you perform calculations (like +, -, , /) to set dynamic values for properties.in css file
width: calc(100% - 50px);
9. What is the difference between
transition
and animation
in CSS?Ans.
transition
: occurs on state change (e.g., hover)animation
: happens automatically using@keyframes
10. How to apply styles only to a specific child element?
Ans.
.container>p:first-child {
color: red;
}
Comments
Post a Comment