CSS Interview Questions
Topics in Focus
- Selectors and Specificity
- Types of selectors (class, ID, attribute, pseudo-classes, pseudo-elements)
- Specificity rules
- Inheritance
- Box Model
- Content, padding, border, and margin
- Box-sizing property
- Understanding different box models (content-box vs border-box)
- Layout Techniques
- Flexbox
- Grid
- Float and clear
- Positioning (static, relative, absolute, fixed, sticky)
- CSS Units (px, em, rem, %, vh, vw)
- Responsive Design
- Media queries
- Mobile-first vs desktop-first approaches
- Viewport meta tag
- Responsive units and techniques
- CSS Animations and Transitions
- Keyframes
- Transition property
- Animation property
- Preprocessors and Architecture
- SASS/SCSS, LESS
- BEM (Block Element Modifier)
- CSS Modules
- CSS-in-JS
- Performance and Optimization
- Critical rendering path
- Minification and concatenation
- Reducing reflows and repaints
- Lazy loading of styles
- CSS Variables (Custom Properties)
- Defining and using CSS variables
- Scope and inheritance of variables
- Accessibility
- CSS techniques for accessible design
- Focus management
- Using ARIA roles and properties
- Advanced Techniques
- CSS Grid advanced properties (grid-template-areas, minmax, auto-fill)
- Advanced selectors (nth-child, nth-of-type)
- CSS Houdini
Interview Questions
- Selectors and Specificity
- What are the different types of CSS selectors and how do they work?
- Explain the CSS specificity hierarchy. How would you resolve specificity conflicts?
- How does inheritance work in CSS? Can you provide an example?
- Box Model
- Explain the CSS box model and how you can change the box model used by an element.
- How do padding, margin, and border affect the size of an element?