Tailwind Mastery: Challenging Tailwind CSS Interview Questions Quiz

  1. Understanding Utility-First

    Which principle best describes the utility-first approach used by Tailwind CSS, as opposed to conventional CSS methodologies?

    1. A. Writing large CSS files with component classes
    2. B. Using small, single-purpose classes to construct UI directly in HTML
    3. C. Emphasizing inheritance over composition
    4. D. Adopting global CSS resets by default
    5. E. Relying on pre-built user interface components exclusively
  2. Config Customization

    In the Tailwind CSS config file, which key would you update to add a custom background color called 'brand-blue'?

    1. A. variants.extend.backgroundColor
    2. B. plugins.colors
    3. C. theme.extend.backgroundColor
    4. D. purge.backgroundColor
    5. E. theme.custom.background
  3. Purging Unused CSS

    What is the main function of the 'purge' option in tailwind.config.js?

    1. A. To minify all JavaScript files in production
    2. B. To remove unused CSS utilities from the final build
    3. C. To reset all browser default styles
    4. D. To generate custom utility classes
    5. E. To load external CSS frameworks
  4. Variants in Practice

    When customizing variants in the Tailwind config file, which scenario best illustrates their purpose?

    1. A. Adding new fonts to the default theme
    2. B. Allowing a utility class to respond to 'focus' and 'hover' states
    3. C. Creating nested CSS classes for child selectors
    4. D. Adding a new color palette
    5. E. Compiling Sass files automatically
  5. Using @apply

    Given a custom CSS class '.btn-primary' that should include Tailwind's 'bg-blue-500' and 'text-white', which feature allows this composition?

    1. A. @add
    2. B. @apply
    3. C. @compose
    4. D. @import
    5. E. @include
  6. Plugin Extension

    Suppose you want to add custom utilities globally to your Tailwind project. Where should you register a third-party plugin?

    1. A. In the variants section
    2. B. Within the extend object under theme
    3. C. In the plugins array of tailwind.config.js
    4. D. In the purge section
    5. E. As a direct import in main.js
  7. Theme Extension

    What is the recommended way to add new spacing values to Tailwind's spacing scale without overwriting the defaults?

    1. A. Modify the theme.spacing object directly
    2. B. Add new values under theme.extend.spacing
    3. C. Insert values in variants.spacing
    4. D. Place values in plugins.spacing
    5. E. Update purge.spacing with new values
  8. Responsive Design

    How does Tailwind CSS enable you to apply different styles at various screen sizes in your HTML code?

    1. A. Using @media queries inside custom CSS files
    2. B. By adding responsive prefixes like 'md:' to utility classes
    3. C. Defining breakpoints in the purge section
    4. D. Using only JavaScript to modify classes on resize
    5. E. Setting .responsive attribute on HTML elements
  9. Custom Fonts

    If you want to add a new font family called 'Headline' to your Tailwind project, which config structure is correct?

    1. A. theme.extend.fonts.Headline = 'Helvetica, Arial'
    2. B. theme.fontFamily = ['Headline', 'serif']
    3. C. theme.extend.fontFamily['headline'] = ['Headline', 'sans-serif']
    4. D. theme.fontFamily.headline = ['Headline', 'sans-serif']
    5. E. extend.theme.fontFamily['headline'] = ['Headline', 'sans-serif']
  10. Building Custom Utilities

    Which approach lets you define a custom utility class that utilizes multiple Tailwind classes (e.g., combining 'uppercase', 'p-4', and 'tracking-wide')?

    1. A. Use @import followed by the classes
    2. B. Define the class in your CSS and use the @apply directive with those utilities
    3. C. Combine the classes in tailwind.config.js under theme.utilities
    4. D. List the utilities under variants in tailwind.config.js
    5. E. Register the class in the plugins array only