Bird
Raised Fist0
Tailwindmarkup~10 mins

Square bracket notation for custom values 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 set a custom width of 72 pixels using Tailwind's square bracket notation.

Tailwind
<div class="w-[1] bg-blue-500 text-white p-4">Custom width box</div>
Drag options to blanks, or click blank then click option'
Awidth-72
B72
Cw-72
D[72px]
Attempts:
3 left
💡 Hint
Common Mistakes
Using just '72' without brackets and units.
Using 'w-72' which is a predefined size, not custom.
Using 'width-72' which is not valid Tailwind syntax.
2fill in blank
medium

Complete the code to set a custom background color of #123abc using Tailwind's square bracket notation.

Tailwind
<div class="bg-[1] text-white p-4">Custom color box</div>
Drag options to blanks, or click blank then click option'
A123abc
B[#123abc]
Cbg-123abc
Dcolor-#123abc
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the hash symbol (#).
Not using square brackets around the color code.
Using 'bg-123abc' which Tailwind does not recognize as a custom color.
3fill in blank
hard

Fix the error in the code to apply a custom margin of 15 pixels using Tailwind's square bracket notation.

Tailwind
<div class="m-[1] p-2">Margin box</div>
Drag options to blanks, or click blank then click option'
A[15px]
B[15]
Cm-15px
D15
Attempts:
3 left
💡 Hint
Common Mistakes
Using '15' without units or brackets.
Using '[15]' without units.
Using 'm-15px' which is not valid Tailwind syntax.
4fill in blank
hard

Fill both blanks to set a custom padding of 10 pixels and a custom font size of 18 pixels using Tailwind's square bracket notation.

Tailwind
<p class="p-[1] text-[2]">Custom padded text</p>
Drag options to blanks, or click blank then click option'
A[10px]
B[18px]
C18px
D10px
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting square brackets.
Leaving out units like 'px'.
Using plain numbers without brackets.
5fill in blank
hard

Fill all three blanks to create a div with a custom width of 100 pixels, height of 50 pixels, and background color #ff6600 using Tailwind's square bracket notation.

Tailwind
<div class="w-[1] h-[2] bg-[3]">Custom box</div>
Drag options to blanks, or click blank then click option'
A[100px]
B[50px]
C[#ff6600]
D100px
Attempts:
3 left
💡 Hint
Common Mistakes
Not using square brackets.
Omitting units for width and height.
Leaving out the hash symbol for the color.

Practice

(1/5)
1. What does the square bracket notation in Tailwind CSS allow you to do?
easy
A. Disable Tailwind's default styles
B. Write JavaScript code inside Tailwind classes
C. Create new Tailwind utility classes permanently
D. Use custom CSS values not included in Tailwind's default set

Solution

  1. Step 1: Understand Tailwind's default values

    Tailwind provides a set of predefined values for spacing, colors, sizes, etc.
  2. Step 2: Role of square bracket notation

    Square bracket notation lets you write any CSS value directly inside a class, like mt-[10px] for margin-top 10 pixels.
  3. Final Answer:

    Use custom CSS values not included in Tailwind's default set -> Option D
  4. Quick Check:

    Square brackets = custom CSS values [OK]
Hint: Square brackets mean custom CSS values inside Tailwind classes [OK]
Common Mistakes:
  • Thinking it creates new permanent classes
  • Confusing with JavaScript code inside classes
  • Assuming it disables Tailwind styles
2. Which of the following is the correct Tailwind class to set a width of exactly 250 pixels using square bracket notation?
easy
A. width-[250]
B. w-[250px]
C. w-250px
D. w-[250]

Solution

  1. Step 1: Identify correct Tailwind prefix for width

    Tailwind uses w- prefix for width utilities.
  2. Step 2: Use square brackets with full CSS value

    Inside brackets, you must include the unit, so 250px is correct.
  3. Final Answer:

    w-[250px] -> Option B
  4. Quick Check:

    Width with unit inside brackets = w-[250px] [OK]
Hint: Use full CSS value with units inside brackets after utility prefix [OK]
Common Mistakes:
  • Omitting units inside brackets
  • Using wrong prefix like width-
  • Not using brackets for custom values
3. What will be the rendered width of a div with class class="w-[15rem]" in Tailwind CSS?
medium
A. 15 rem units (usually 15 times root font size)
B. 15 pixels
C. 15 percent width
D. 15 viewport width units

Solution

  1. Step 1: Understand the CSS unit inside brackets

    The class w-[15rem] sets width to 15 rem units, where 1 rem equals the root font size (usually 16px).
  2. Step 2: Interpret the rendered size

    15 rem means 15 times the root font size, so it is not pixels or percent but relative to font size.
  3. Final Answer:

    15 rem units (usually 15 times root font size) -> Option A
  4. Quick Check:

    Square bracket value with rem = relative font size width [OK]
Hint: Read units inside brackets literally as CSS units [OK]
Common Mistakes:
  • Assuming rem means pixels
  • Confusing rem with percent or viewport units
  • Ignoring units inside brackets
4. You wrote class="p-[20]" to add padding of 20 pixels, but it doesn't work. What is the error?
medium
A. Padding cannot be customized in Tailwind
B. Square brackets are not allowed for padding
C. Missing unit inside square brackets
D. Class name should be padding-[20px]

Solution

  1. Step 1: Check the syntax of the custom value

    Inside square brackets, you must include the CSS unit, like 20px, not just a number.
  2. Step 2: Understand Tailwind's requirement for units

    Without units, the CSS value is invalid, so the style won't apply.
  3. Final Answer:

    Missing unit inside square brackets -> Option C
  4. Quick Check:

    Always include units inside brackets for custom values [OK]
Hint: Always add units like px, rem inside brackets for spacing [OK]
Common Mistakes:
  • Omitting units inside brackets
  • Using wrong class names like padding-
  • Thinking padding can't be customized
5. You want a button with a background color exactly #1a73e8 and a border radius of 12px using Tailwind's square bracket notation. Which class combination is correct?
hard
A. bg-[#1a73e8] rounded-[12px]
B. bg-#1a73e8 rounded-12px
C. background-[#1a73e8] border-radius-[12px]
D. bg-[#1a73e8] rounded-[12]

Solution

  1. Step 1: Use correct Tailwind prefixes

    Background color uses bg- and border radius uses rounded-.
  2. Step 2: Apply square bracket notation with full CSS values

    Inside brackets, include the full hex color #1a73e8 and the unit 12px for radius.
  3. Step 3: Check for syntax correctness

    bg-[#1a73e8] rounded-[12px] uses correct prefixes and proper bracket notation with units and hash symbol.
  4. Final Answer:

    bg-[#1a73e8] rounded-[12px] -> Option A
  5. Quick Check:

    Use correct prefixes + full CSS values in brackets [OK]
Hint: Use bg- and rounded- with full CSS values inside brackets [OK]
Common Mistakes:
  • Omitting # in hex color
  • Missing units for border radius
  • Using wrong prefixes like background-
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