Questions
32 of 33
1What is a breakpoint in CSS? Why are breakpoints used in responsive web design?
2What is the syntax for setting a breakpoint using a media query?
3What is the syntax for setting a breakpoint using a media query?
4What units are typically used for defining breakpoints (e.g., px, em, rem)?
5What happens if no breakpoints are defined in a responsive layout?
6How do breakpoints help in mobile-first design?
7How does CSS decide which breakpoint to apply when multiple match?
8What’s the difference between min-width and max-width in media queries?
9How can you create a layout that adjusts between two breakpoints?
10What is the difference between device-based breakpoints and content-based breakpoints?
11What is the role of the viewport meta tag in responsive design?
12How do breakpoints help in mobile-first design?
13How does CSS decide which breakpoint to apply when multiple match?
14What’s the difference between min-width and max-width in media queries?
15What is the difference between device-based breakpoints and content-based breakpoints?
16What is the role of the viewport meta tag in responsive design?
17What is the difference between using em and px in defining breakpoints?
18How do you handle overlapping or conflicting breakpoint rules?
19Can breakpoints be combined with CSS Grid or Flexbox?
20How do CSS container queries differ from traditional breakpoints?
21How can you implement responsive typography using breakpoints?
22How can you use logical operators (and, not, only) in media queries?
23How does pixel density (device-pixel-ratio) affect breakpoints?
24What is the difference between min-device-width and min-width?
25How do you use breakpoints in frameworks like Bootstrap or Tailwind CSS?
26How would you write a media query for screens smaller than 768px?
27How would you create a responsive navigation bar using breakpoints?
28How would you handle images that need to resize at specific breakpoints? How can you make font sizes scale smoothly between two breakpoints?
29How would you debug a layout that looks broken at a specific breakpoint?
30How would you optimize breakpoints for tablets vs. phones?
31How can you prevent layout jumps between breakpoints?
32How do you use CSS custom properties (variables) with breakpoints?
33How do breakpoints differ between desktop, tablet, and mobile-first strategies?
32 / 33

How do you use CSS custom properties (variables) with breakpoints?

Using CSS Custom Properties with Breakpoints

CSS custom properties (variables) can be combined with media queries to create adaptive and maintainable responsive designs. By redefining variable values inside different breakpoints, you can easily adjust spacing, font sizes, or colors across screen sizes without repeating styles.

Benefits of Using Variables with Breakpoints
  1. 1

    Keeps code cleaner by centralizing responsive values in one place.

  2. 2

    Makes global updates easier — change one variable instead of multiple rules.

  3. 3

    Improves consistency across responsive layouts.

Example: Responsive Variables with Media Queries

In this example, the base font size and container padding are defined as variables in the :root. As the viewport width increases, the media queries redefine these variables, allowing all elements that use them to scale automatically without changing multiple CSS rules.

Best Practices for Responsive CSS Variables
  1. 1

    Define your main design tokens (spacing, typography, colors) as variables in :root.

  2. 2

    Override only what’s necessary inside each breakpoint.

  3. 3

    Use semantic naming (e.g., --font-size-heading, --space-section) for better readability.

  4. 4

    Test across devices to ensure variable updates work as expected.

Difficulty: 5/10
Topics: variables, responsive design, fallbacks

Scenario Questions

0-2 years experience
  1. 1

    We have a simple card component that needs a different background color on mobile versus desktop. How would you use a CSS custom property to define the color and switch it at a 768px breakpoint?

  2. 2

    If you set a custom property inside a media query but later reference it outside that query, what value will be applied and why?

2-5 years experience
  1. 1

    You’re adding a theme switcher that changes the primary color across breakpoints. After implementing, the color doesn’t change on tablet screens. Walk me through how you’d debug the custom property usage with breakpoints.

  2. 2

    Explain the trade‑offs between defining breakpoint values as custom properties versus hard‑coding them in each media query. When might you choose one over the other?

5-8 years experience
  1. 1

    Our design system uses dozens of custom properties for spacing and typography that need to adapt at multiple breakpoints. How would you structure the CSS (or pre‑processor) to keep the variables maintainable and avoid cascade conflicts?

  2. 2

    Consider a large SPA where CSS is loaded lazily per route. How could using CSS custom properties for breakpoints impact performance, and what strategies would you employ to mitigate any issues?

8+ years experience
  1. 1

    The company is migrating a legacy codebase that uses many static media queries to a new system based on CSS custom properties for breakpoints. What architectural plan would you propose to roll this out across multiple teams while minimizing regressions?

  2. 2

    Discuss the long‑term maintenance implications of storing breakpoint values as custom properties in a shared design token file versus keeping them in JavaScript. How does this affect cross‑platform consistency and tooling?

Follow-up Questions

  • Can you sketch the CSS snippet you would write?
  • What happens if the custom property is not defined at the point of use?
  • How would you provide a fallback for older browsers?