Basic Questions:
What is CSS?
- Explain what CSS (Cascading Style Sheets) is and its purpose in web development.
What is the difference between
classandidselectors in CSS?- Explain when to use a class selector versus an ID selector and their specificity.
What are the different types of CSS?
- Inline, internal (within
<style>tag), and external (linked through a.cssfile).
- Inline, internal (within
What is the CSS box model?
- Explain the components (content, padding, border, and margin) of the box model.
Explain the concept of specificity in CSS.
- How do browser's CSS rules get applied based on specificity (inline styles, IDs, classes, element selectors)?
What is Flexbox, and how is it used?
- Explain what Flexbox is and provide examples of when to use
display: flex,justify-content,align-items, etc.
- Explain what Flexbox is and provide examples of when to use
What is a CSS pseudo-class?
- Give examples of common pseudo-classes (e.g.,
:hover,:nth-child,:focus).
- Give examples of common pseudo-classes (e.g.,
Explain the difference between
absolute,relative,fixed, andstickypositioning in CSS.- When and why to use each positioning method.
What is the difference between
visibility: hiddenanddisplay: none?- Explain how these properties affect the layout and visibility of elements.
How would you create a CSS Grid layout?
- Explain the
display: gridproperty and how to define rows and columns usinggrid-template-columnsandgrid-template-rows.
- Explain the
Advanced Questions:
What are CSS preprocessors? Have you used any?
- Describe CSS preprocessors like Sass or LESS and how they extend CSS with variables, nesting, and mixins.
What is the difference between
remandemin CSS?- Explain how these units are calculated and their use cases.
What are media queries in CSS?
- Explain how media queries are used for responsive design and show examples.
Explain the concept of inheritance in CSS.
- Discuss how properties get inherited by child elements and how to manage inheritance.
What is
z-indexand how does it work?- Explain the stacking context and how
z-indexaffects the layering of elements.
- Explain the stacking context and how
What is the difference between
@importand linking a CSS file?- Explain performance differences between the two methods.
Explain the concept of reflow and repaint in CSS.
- Describe what causes reflows and repaints in browsers and how to optimize them.
What are CSS transitions and animations?
- Explain how to create smooth transitions and keyframe animations.
How do you implement a responsive design in CSS?
- Discuss strategies for creating responsive designs using media queries, flexbox, grid, and viewport units.
What is the
will-changeproperty in CSS, and when would you use it?- Explain how the
will-changeproperty is used to optimize performance during animations or layout changes.
- Explain how the
Practical/Code Challenges:
- Center a
divboth vertically and horizontally on a page. - Create a 2-column layout with flexbox.
- How would you make a button change color on hover using CSS?
These questions will help you cover both theoretical knowledge and practical CSS scenarios that could be part of an interview
