Arbitrary values let you use custom styles not included in Tailwind's default set by writing them directly in square brackets, like <code>bg-[#123456]</code> for a custom color.
Click to reveal answer
beginner
Why does Tailwind allow arbitrary values?
Because sometimes you need a style that Tailwind doesn’t have built-in. Arbitrary values let you add those exact styles without writing extra CSS files.
Click to reveal answer
intermediate
How do arbitrary values improve developer experience?
They save time by letting you write one-off styles quickly in your HTML or JSX, avoiding switching between files or writing custom CSS.
Click to reveal answer
beginner
Give an example of an arbitrary value for padding in Tailwind.
You can write p-[13px] to set padding exactly to 13 pixels, even if Tailwind doesn’t have that size predefined.
Click to reveal answer
intermediate
What is a potential downside of using too many arbitrary values?
Using many arbitrary values can make your code harder to read and maintain because styles are less consistent and harder to find in one place.
Click to reveal answer
What syntax does Tailwind use for arbitrary values?
ACurly braces around the value, like <code>text-{20px}</code>
BNo special syntax, just write the value directly
CParentheses around the value, like <code>text-(20px)</code>
DSquare brackets around the value, like <code>text-[20px]</code>
✗ Incorrect
Tailwind uses square brackets to wrap arbitrary values, for example text-[20px].
Why might you use an arbitrary value instead of a default Tailwind class?
ATo use a style size or color not included in Tailwind's presets
BBecause arbitrary values are faster to load
CTo avoid writing any CSS at all
DBecause Tailwind does not support responsive design
✗ Incorrect
Arbitrary values let you use custom sizes or colors not in Tailwind’s default set.
Which of these is a valid arbitrary value for background color in Tailwind?
Abg-(#ff5733)
Bbg-[#ff5733]
Cbg-{#ff5733}
Dbg-ff5733
✗ Incorrect
The correct syntax uses square brackets: bg-[#ff5733].
What is a risk of overusing arbitrary values?
ACode becomes harder to maintain and less consistent
BTailwind will stop working
CYour website will load slower
DYou cannot use responsive design anymore
✗ Incorrect
Too many arbitrary values can make your code messy and inconsistent.
How do arbitrary values help with responsive design?
AThey disable responsiveness for that element
BThey automatically adjust sizes on different screens
CYou can combine them with responsive prefixes like <code>md:p-[15px]</code>
DThey replace media queries
✗ Incorrect
You can use arbitrary values with responsive prefixes to set custom styles at different screen sizes.
Explain why Tailwind CSS includes arbitrary values and how they help developers.
Think about times when you need a style Tailwind doesn’t have.
You got /4 concepts.
Describe the syntax for using arbitrary values in Tailwind and give two examples.
Remember the brackets and how you write the value inside.
You got /3 concepts.
Practice
(1/5)
1. Why do arbitrary values exist in Tailwind CSS?
easy
A. To allow using any custom CSS value beyond default Tailwind options
B. To restrict styling only to predefined Tailwind classes
C. To automatically generate animations
D. To replace JavaScript functionality
Solution
Step 1: Understand Tailwind's default options
Tailwind provides many predefined classes but cannot cover every possible CSS value.
Step 2: Purpose of arbitrary values
Arbitrary values let you write any CSS value inside square brackets to customize styles beyond defaults.
Final Answer:
To allow using any custom CSS value beyond default Tailwind options -> Option A
Quick Check:
Arbitrary values = custom CSS values [OK]
Hint: Think: Custom styles beyond presets use arbitrary values [OK]
Common Mistakes:
Thinking arbitrary values limit styling
Confusing arbitrary values with animations
Believing arbitrary values replace JavaScript
2. Which of the following is the correct syntax to set a custom width of 450 pixels using Tailwind's arbitrary values?
easy
A. width-450
B. w-[450px]
C. w-450px
D. width-[450]
Solution
Step 1: Recall Tailwind arbitrary value syntax
Arbitrary values use square brackets with the CSS value inside, e.g., w-[450px].
Step 2: Check each option
Only w-[450px] uses square brackets and includes units correctly.
Final Answer:
w-[450px] -> Option B
Quick Check:
Correct syntax = w-[450px] [OK]
Hint: Remember: square brackets around full CSS value with units [OK]
Common Mistakes:
Omitting square brackets
Missing units like px
Using dash instead of brackets
3. What will be the width of the div rendered by this code?
C. Width of 30rem (about 480px) with blue background
D. Width of 30rem but no background color
Solution
Step 1: Interpret the class w-[30rem]
This sets the width to exactly 30rem, which is about 480 pixels (1rem ≈ 16px).
Step 2: Check other classes
bg-blue-500 sets a blue background, text-white sets white text, and p-4 adds padding.
Final Answer:
Width of 30rem (about 480px) with blue background -> Option C
Quick Check:
Arbitrary width 30rem + blue bg = Width of 30rem (about 480px) with blue background [OK]
Hint: Remember rem units scale with root font size (~16px) [OK]
Common Mistakes:
Confusing rem with px
Ignoring background color class
Assuming default width
4. Identify the error in this Tailwind class usage:
<div class="h-[100] bg-red-400">Error</div>
medium
A. Missing units inside the arbitrary value brackets
B. Incorrect use of square brackets
C. bg-red-400 is not a valid Tailwind class
D. Height cannot be set with arbitrary values
Solution
Step 1: Check the arbitrary value syntax
The height is set as h-[100] but lacks units like px or rem.
Step 2: Understand CSS requirements
CSS requires units for length values unless it's zero; so 100 alone is invalid.
Final Answer:
Missing units inside the arbitrary value brackets -> Option A
Quick Check:
Units required inside brackets [OK]
Hint: Always include units like px or rem inside brackets [OK]
Common Mistakes:
Forgetting units inside arbitrary values
Thinking brackets are wrong syntax
Assuming Tailwind classes are invalid
5. You want to create a button with a custom border radius of 12px and a padding of 1.25rem using Tailwind. Which class combination correctly uses arbitrary values to achieve this?
hard
A. rounded-12px p-1.25rem
B. rounded-12 p-1.25rem
C. rounded-[12] p-[1.25]
D. rounded-[12px] p-[1.25rem]
Solution
Step 1: Use square brackets for arbitrary values
Custom values must be inside square brackets with units, e.g., rounded-[12px] and p-[1.25rem].
Step 2: Check each option
Only rounded-[12px] p-[1.25rem] correctly uses brackets and includes units for both border radius and padding.
Final Answer:
rounded-[12px] p-[1.25rem] -> Option D
Quick Check:
Arbitrary values need brackets + units [OK]
Hint: Use brackets and units for all custom CSS values [OK]
Common Mistakes:
Omitting brackets
Leaving out units
Mixing syntax without brackets
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.