Bird
Raised Fist0
Tailwindmarkup~10 mins

Custom breakpoints in Tailwind - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a custom breakpoint named 'tablet' with a minimum width of 640px.

Tailwind
module.exports = {
  theme: {
    screens: {
      tablet: '[1]',
    },
  },
}
Drag options to blanks, or click blank then click option'
A"480px"
B"768px"
C"640px"
D"1024px"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong pixel value like 768px or 1024px.
Not including the pixel unit in quotes.
2fill in blank
medium

Complete the code to apply a background color only on screens wider than the custom 'tablet' breakpoint.

Tailwind
<div class="[1]:bg-blue-500 bg-red-500 p-4">
  Responsive box
</div>
Drag options to blanks, or click blank then click option'
Amobile
Btablet
Cdesktop
Dsm
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent breakpoint name like 'mobile'.
Forgetting the colon after the breakpoint name.
3fill in blank
hard

Fix the error in the custom breakpoint definition to use the correct syntax for a min-width media query.

Tailwind
module.exports = {
  theme: {
    screens: {
      tablet: '[1]',
    },
  },
}
Drag options to blanks, or click blank then click option'
A"(min-width: 640px)"
B"min-width: 640px"
C"640px"
D"min-width=640px"
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting parentheses around the media query.
Using '=' instead of ':' in the media query.
4fill in blank
hard

Fill both blanks to define two custom breakpoints: 'tablet' at 640px and 'laptop' at 1024px.

Tailwind
module.exports = {
  theme: {
    screens: {
      tablet: '[1]',
      laptop: '[2]',
    },
  },
}
Drag options to blanks, or click blank then click option'
A"640px"
B"768px"
C"1024px"
D"1280px"
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the pixel values for tablet and laptop.
Forgetting quotes around the pixel values.
5fill in blank
hard

Fill all three blanks to create a responsive text size: small on mobile, medium on tablet, and large on laptop.

Tailwind
<p class="text-[1] [2]:text-[3] laptop:text-lg">
  Responsive text
</p>
Drag options to blanks, or click blank then click option'
Asm
Bbase
Ctablet
Dlg
Attempts:
3 left
💡 Hint
Common Mistakes
Using breakpoint names as text sizes or vice versa.
Forgetting the colon after the breakpoint prefix.

Practice

(1/5)
1. What is the main purpose of defining custom breakpoints in Tailwind CSS?
easy
A. To add new colors to the palette
B. To change font sizes globally
C. To create custom animations
D. To control when styles change based on screen width

Solution

  1. Step 1: Understand what breakpoints do

    Breakpoints let you apply different styles depending on screen size.
  2. Step 2: Identify the role of custom breakpoints

    Custom breakpoints let you choose specific screen widths for style changes.
  3. Final Answer:

    To control when styles change based on screen width -> Option D
  4. Quick Check:

    Breakpoints = screen width control [OK]
Hint: Breakpoints control style changes by screen size [OK]
Common Mistakes:
  • Confusing breakpoints with colors or fonts
  • Thinking breakpoints create animations
  • Assuming breakpoints change global styles
2. Which is the correct way to define a custom breakpoint named tablet at 768px in tailwind.config.js?
easy
A. "screens": { "tablet": "768px" }
B. "screens": { "tablet": 768 }
C. "breakpoints": { "tablet": "768px" }
D. "screens": { "tablet": "768" }

Solution

  1. Step 1: Identify the correct config key

    Custom breakpoints go under the "screens" key in tailwind.config.js.
  2. Step 2: Use correct value format

    Breakpoint values must be strings with units, e.g., "768px".
  3. Final Answer:

    "screens": { "tablet": "768px" } -> Option A
  4. Quick Check:

    screens + "768px" string = correct syntax [OK]
Hint: Use "screens" key with pixel string values [OK]
Common Mistakes:
  • Using number without units
  • Using wrong key like "breakpoints"
  • Omitting "px" unit in value
3. Given this config snippet:
module.exports = { theme: { screens: { 'md': '640px', 'lg': '1024px', 'xl': '1280px' } } }

Which class applies padding only on screens 1024px wide or larger?
medium
A. lg:p-4
B. p-lg-4
C. md:p-4
D. xl:p-4

Solution

  1. Step 1: Understand breakpoint prefixes

    Tailwind uses breakpoint names as prefixes followed by a colon, e.g., "lg:".
  2. Step 2: Match breakpoint to screen size

    "lg" is 1024px, so "lg:p-4" applies padding at 1024px and above.
  3. Final Answer:

    lg:p-4 -> Option A
  4. Quick Check:

    Prefix "lg:" = 1024px+ padding [OK]
Hint: Use breakpoint name + colon before class [OK]
Common Mistakes:
  • Using breakpoint name after class (wrong order)
  • Missing colon after breakpoint
  • Confusing md and lg breakpoints
4. You added a custom breakpoint tablet at 768px but your styles using tablet:bg-red-500 don't apply. What is the likely error?
medium
A. You defined tablet under colors instead of screens
B. You used tablet: prefix instead of tablet-
C. You forgot to restart the Tailwind build process after config change
D. You wrote tablet: bg-red-500 with a space

Solution

  1. Step 1: Check config changes effect

    Tailwind requires restarting the build to load new config values.
  2. Step 2: Verify syntax and placement

    Using "tablet:bg-red-500" is correct syntax; spacing or wrong keys cause errors but less likely here.
  3. Final Answer:

    You forgot to restart the Tailwind build process after config change -> Option C
  4. Quick Check:

    Restart build after config edits [OK]
Hint: Restart Tailwind build after config edits [OK]
Common Mistakes:
  • Using dash (-) instead of colon (:) in class prefix
  • Defining breakpoint in wrong config section
  • Adding spaces inside class names
5. You want a layout that shows a sidebar only on screens wider than 900px. You defined a custom breakpoint desktop at 900px. Which Tailwind class setup correctly hides the sidebar on smaller screens and shows it on desktop and larger?
hard
A. block hidden:desktop
B. hidden desktop:block
C. block desktop:hidden
D. desktop:hidden block

Solution

  1. Step 1: Understand default and breakpoint styles

    "hidden" hides element by default (all screens). "desktop:block" shows it at 900px+.
  2. Step 2: Match classes to desired behavior

    Using "hidden desktop:block" hides sidebar on small screens and shows on desktop and larger.
  3. Final Answer:

    hidden desktop:block -> Option B
  4. Quick Check:

    hidden + breakpoint:block = show on breakpoint [OK]
Hint: Use hidden by default, breakpoint:block to show [OK]
Common Mistakes:
  • Reversing hidden and block classes
  • Using breakpoint:hidden instead of breakpoint:block
  • Incorrect class order or syntax
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard