CSS_Interview_Questions
CSS_Interview_Questions
What is CSS?
CSS (Cascading Style Sheets) is a language used to style the appearance of HTML elements
on a web page. It controls layout, color, fonts, and more.
What is the difference between position: absolute, relative, fixed, and sticky?
absolute: Positioned relative to the nearest positioned ancestor. relative: Positioned relative
to its normal position. fixed: Positioned relative to the viewport. sticky: Switches between
relative and fixed positioning based on the scroll position.
What is the z-index property in CSS?
The `z-index` property controls the vertical stacking order of elements. Elements with a
higher `z-index` appear on top of elements with a lower `z-index`.
What are CSS preprocessors, and how do they differ from CSS?
CSS preprocessors like SASS, LESS, and Stylus extend CSS with features like variables,
nested rules, and functions. They require compilation into standard CSS.
What is the difference between display: none and visibility: hidden in CSS?
display: none removes the element from the document flow, while visibility: hidden hides
the element but maintains its space in the layout.
How does the min-width and max-width properties help in responsive design?
min-width sets a minimum width for an element, ensuring it doesn’t shrink below a certain
size, while max-width limits how wide an element can grow. Both help in creating layouts
that adapt to various screen sizes.
What is the difference between rem and em units in CSS?
rem is relative to the root element’s font size, while em is relative to the font size of its
parent element. rem provides more consistency in sizing across elements.