Fundamentals Beginner
What is CSS?
CSS is the styling language browsers use to control presentation, layout, and visual states for HTML documents. It maps selectors to declarations, then the browser resolves those declarations through the cascade and computes final styles. CSS can fail in surprising ways because multiple rules, inherited values, browser defaults, and responsive constraints all interact.
Review CSS basics → Cascade + selectors Intermediate
How does the CSS cascade work?
The cascade decides which declaration wins when more than one rule applies to the same property. It evaluates origin, importance, cascade layers, specificity, scoping proximity, and source order. Source order only wins after the higher-priority cascade factors are tied.
Review cascade order → Cascade + selectors Intermediate
What is CSS specificity?
Specificity is the selector weight used when competing declarations are in the same origin and layer. Inline styles, IDs, classes or attributes, and element selectors carry different weight. Specificity fixes can become a maintenance problem when every override needs a stronger selector.
Practice specificity → Cascade + selectors Beginner
What is inheritance in CSS?
Inheritance lets some computed values pass from parent elements to children. Text-related properties such as color and font-family commonly inherit, while layout properties such as margin and border usually do not. Bugs happen when a component unexpectedly receives typography, color, or custom property values from a parent context.
Fundamentals Beginner
What is the CSS box model?
The box model describes how content, padding, border, and margin create an element box and spacing around it. With content-box, width applies only to content; with border-box, width includes padding and border. Many layout bugs come from mixing those sizing assumptions in the same component.
Review the box model → Fundamentals Beginner
What is the difference between margin and padding?
Padding creates space inside an element between its content and border. Margin creates space outside the element between it and neighboring boxes. Margin can collapse vertically in normal flow, while padding affects the element box and background area.
Compare margin and padding → Layout Beginner
How does display affect layout?
The display property controls how an element generates boxes and how its children participate in layout. Block, inline, flex, grid, and none all create very different layout behavior. Changing display can also change whether width, height, alignment, and child placement rules apply.
Review display and Flexbox → Layout Beginner
When should you use Flexbox?
Flexbox is best for one-dimensional layouts where items need alignment, distribution, wrapping, or ordering along a row or column. It is well suited for nav bars, toolbars, centered content, and small component internals. For layout where rows and columns both matter, Grid is usually clearer.
Review Flexbox → Layout Intermediate
When should you use CSS Grid?
CSS Grid is best for two-dimensional layouts where rows and columns need to be controlled together. It handles page regions, card galleries, dashboards, and layouts with explicit tracks or areas. It can be more structure than needed for a single row of aligned controls.
Compare Grid and Flexbox → Layout Intermediate
How does CSS positioning work?
Positioning controls whether an element stays in normal flow and what box its offsets use. Relative keeps its original space, absolute positions against a containing block, fixed uses the viewport, and sticky switches as the user scrolls. Positioning bugs often come from the wrong containing block or scroll container.
Review positioning → Layout Advanced
What is a stacking context?
A stacking context is a layer group where child z-index values are compared internally. Transforms, opacity, filters, positioned elements, isolation, and other properties can create new stacking contexts. An element with a large z-index can still appear behind another element if its parent context is lower.
Debug stacking contexts → Layout Intermediate
How does z-index work?
z-index controls stacking order only for positioned or stacking-context-aware elements. It does not create a global ranking across the whole page. If two elements are in different stacking contexts, changing the child z-index may not change which one appears on top.
Review z-index → Responsive Intermediate
How do rem, em, px, and percent differ?
px is an absolute CSS pixel unit, rem is relative to the root font size, em is relative to the current element font size, and percent depends on the property and containing context. rem is predictable for global spacing and type scales, while em is useful for component-relative sizing. Percent values can surprise you because width, height, transforms, and padding can use different reference boxes.
Review CSS units → Responsive Beginner
What are media queries used for?
Media queries apply CSS when viewport, device, environment, or user preference conditions match. They are used for responsive layouts, reduced motion, color scheme, print styles, and input capabilities. Good media queries respond to layout constraints instead of copying a fixed list of device sizes.
Review media queries → Responsive Advanced
What are container queries?
Container queries let a component adapt to the size or style context of its container instead of only the viewport. They are useful when the same component appears in a sidebar, grid, and full-width region. The component needs a defined query container, otherwise the query has no useful container to evaluate.
Responsive Beginner
What does responsive design mean in CSS?
Responsive design means the UI adapts to different widths, input modes, zoom levels, content lengths, and user preferences. CSS tools include fluid units, media queries, container queries, flexible tracks, wrapping, and stable aspect ratios. A responsive layout should be tested with long content and narrow widths, not only common device presets.
Practice responsive CSS → Cascade + selectors Intermediate
What are CSS custom properties?
CSS custom properties are variables declared with names like --space and read with var(). They cascade and inherit, so themes and component overrides can be controlled at runtime. The risk is accidental inheritance or missing fallbacks that make a component pick up the wrong value.
Review custom properties → Cascade + selectors Intermediate
What are pseudo-classes and pseudo-elements?
Pseudo-classes select elements in a state, such as :hover, :focus-visible, :checked, or :nth-child(). Pseudo-elements style generated parts of an element, such as ::before, ::after, or ::marker. Focus styles are a practical edge case because removing outlines globally breaks keyboard navigation.
Review pseudo selectors → Debugging + performance Intermediate
What is BEM in CSS?
BEM is a naming convention that separates blocks, elements, and modifiers to make selector intent explicit. It avoids deep descendant selectors and helps teams reason about component state. It is a convention, not a browser feature, so it works only when the team applies it consistently.
Debugging + performance Advanced
How do you debug CSS overflow?
Find the element that is wider or taller than its container, then inspect fixed widths, min-width defaults, grid tracks, absolute positioning, and long unwrapped text. Flex and grid children often need min-width: 0 or min-height: 0 to shrink correctly. Hiding overflow can mask the problem while making content or focus unreachable.
Fix responsive overflow → Responsive Intermediate
How do min-width and max-width affect responsive layout?
min-width prevents an element from shrinking below a threshold, while max-width prevents it from growing beyond a threshold. They are useful for readable cards, text columns, and media, but they can also create overflow if the minimum is too large. In flex and grid layouts, automatic minimum sizes are a common reason content refuses to shrink.
Practice responsive sizing → Debugging + performance Intermediate
How do transforms and transitions differ?
Transforms change how an element is visually moved, scaled, rotated, or skewed without changing normal document flow. Transitions animate a property change between two states. Transform and opacity animations are usually cheaper than animating layout properties like width, height, or top.
Debugging + performance Intermediate
How should CSS animations be used safely?
CSS animations should support the UI state without delaying essential information or causing motion discomfort. Use prefers-reduced-motion to simplify or remove nonessential motion for users who request it. Animating layout-heavy properties can create performance problems on slower devices.
Review media features → Debugging + performance Advanced
How do you improve CSS performance?
Start by measuring whether the problem is style recalculation, layout, paint, compositing, or JavaScript. Prefer stable layout dimensions, avoid repeated layout reads after writes, and animate transform or opacity when possible. Hardware acceleration can help specific compositing cases, but it is not a universal fix.
Review CSS performance → Debugging + performance Advanced
How do you debug a CSS layout bug?
Inspect the element in DevTools, check the computed styles, and identify the actual constraint that fails. Then isolate cascade conflicts, box sizing, display mode, positioning, overflow, and responsive breakpoints. Guessing from the stylesheet alone is slower because the live DOM state may differ from the source you are reading.
Practice layout debugging →